Difference between revisions of "Keyboard Module"
m (Protected "Keyboard Module" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
(→virtualRelease) |
||
Line 76: | Line 76: | ||
Attempts to send a synthetic release for the given key, and sends that input directly to the given window. | Attempts to send a synthetic release for the given key, and sends that input directly to the given window. | ||
+ | |||
+ | |||
+ | == getKeyName == | ||
+ | '''string keyboard.getKeyName(number vk)''' | ||
+ | |||
+ | Returns the name of a key (given by virtual key code) as a string. |
Revision as of 23:34, 29 September 2014
Most keyboard functions will expect a virtual key code. Use the Key Module for getting the proper VK.
Contents
pressed
boolean keyboard.pressed(number vk)
Returns true if the given key was pressed in this logic cycle. It does not continually return true when a key is held down, only once when it is initially pressed.
released
boolean keyboard.released(number vk)
Returns true if the given key was released in this logic cycle. It does not continually return true when a key not held down, only once when it is initially released.
isDown
boolean keyboard.isDown(number vk)
Returns true if the given key is held down. This will continue to return true as long as the key is held down.
getToggleState
boolean keyboard.getToggleState(number vk)
Returns the toggle state (true = on, false = off) for the given key identified by vk. For example, you can check if Caps Lock is on with the following:
print("Caps lock ?", keyboard.getToggleState(key.VK_CAPSLOCK));
press
keyboard.press(number vk)
Attempts to send a synthetic press for the given key. If async is true (default), it is queued for automatic release. Otherwise, execution is blocked while waiting for release.
This will send the input to whichever window has input focus at the time.
hold
keyboard.hold(number vk)
Attempts to send a synthetic hold for the given key. As there is no automatically-paired release, the async flag is not accepted in this function.
This will send the input to whichever window has input focus at the time.
release
keyboard.release(number vk)
Attempts to send a synthetic release for the given key. You should typically use keyboard.hold() on the key first to give it something to release.
This will send the input to whichever window has input focus at the time.
virtualPress
keyboard.virtualPress(number hwnd, number vk[, boolean async])
Attempts to send a synthetic press for the given key, and sends that input directly to the given window. If async is true (default), it is queued for automatic release. Otherwise, execution is blocked while waiting for release.
As virtual functions send the input directly to the specified window's input queue, this can be used to control windows that are in the background without interrupting the user.
virtualHold
keyboard.virtualHold(number hwnd, number vk)
Attempts to send a synthetic hold for the given key, and sends that input directly to the given window.
virtualRelease
keyboard.virtualRelease(number hwnd, number vk)
Attempts to send a synthetic release for the given key, and sends that input directly to the given window.
getKeyName
string keyboard.getKeyName(number vk)
Returns the name of a key (given by virtual key code) as a string.