WoW:UIHANDLER OnKeyDown: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(initial content now that I know it sort of works)
 
m (Move page script moved page UIHANDLER OnKeyDown to UIHANDLER OnKeyDown without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 4: Line 4:


The OnKeyDown handler is called when the user first hits a key and this frame is registered for keyboard events with [[API Frame EnableKeyboard|Frame:EnableKeyboard]].  See also [[UIHANDLER OnKeyUp|OnKeyUp]].
The OnKeyDown handler is called when the user first hits a key and this frame is registered for keyboard events with [[API Frame EnableKeyboard|Frame:EnableKeyboard]].  See also [[UIHANDLER OnKeyUp|OnKeyUp]].
It should also be noted that the [[frameStrata]] has to be at least DIALOG or higher for this to work.


Note that if you think you want to use this handler to take an in-game action based on a keypress, you probably really want to enable the <code>runOnUp</code> attribute of a key binding, and check the <code>keystate</code> variable and act accordingly.  See [[HOWTO: Use Bindings.xml to create key bindings for your AddOn]].  This handler is more appropriate for cases where you want to allow freeform text entry and an [[UIOBJECT EditBox|EditBox]] isn't flexible enough.
Note that if you think you want to use this handler to take an in-game action based on a keypress, you probably really want to enable the <code>runOnUp</code> attribute of a key binding, and check the <code>keystate</code> variable and act accordingly.  See [[HOWTO: Use Bindings.xml to create key bindings for your AddOn]].  This handler is more appropriate for cases where you want to allow freeform text entry and an [[UIOBJECT EditBox|EditBox]] isn't flexible enough.

Latest revision as of 04:49, 15 August 2023

Widget handlers < OnKeyDown

Description[edit]

The OnKeyDown handler is called when the user first hits a key and this frame is registered for keyboard events with Frame:EnableKeyboard. See also OnKeyUp.

It should also be noted that the frameStrata has to be at least DIALOG or higher for this to work.

Note that if you think you want to use this handler to take an in-game action based on a keypress, you probably really want to enable the runOnUp attribute of a key binding, and check the keystate variable and act accordingly. See HOWTO: Use Bindings.xml to create key bindings for your AddOn. This handler is more appropriate for cases where you want to allow freeform text entry and an EditBox isn't flexible enough.

Arguments[edit]

arg1 - returned as a string representing the key that was pressed. For example, "W" or "A" or "S" or "D" (main keyboard keys) or "UP" or "LEFT" or "DOWN" or "RIGHT" (arrow keys) or "DELETE" or other extended keys or "SHIFT" or other modifier keys.