Core Function RealGetKeyState
From Sputnik Wiki
RealGetKeyState( <vk_keycode/expression> )
Contents |
Description
Checks if a key or series of keys is pressed down.
Parameters
vk_keycode/expression
If this param is numeric then a virtual key code (See Macros) is needed.
If this param is a string then it will check all the chars in the string + any specials see remarks.
Return Value
Success: Returns 1.
Failure: Returns 0.
Remarks
Special symbols to use when the param is a string
! Alt Key ^ Control Key + Shift Key # Windows Key
Special {} to use when the param is a string
{SPACE} SPACE {ENTER} ENTER key on the main keyboard {ALT} ALT {BACKSPACE} or {BS} BACKSPACE {DELETE} or {DEL} DELETE {UP} Cursor up {DOWN} Cursor down {LEFT} Cursor left {RIGHT} Cursor right {HOME} HOME {END} END {ESCAPE} or {ESC} ESCAPE {INSERT} or {INS} INS {PGUP} PageUp {PGDN} PageDown {F1} - {F12} Function keys {TAB} TAB {PRINTSCREEN} Print Screen key {LWIN} Left Windows key {RWIN} Right Windows key {NUMLOCK} NUMLOCK {CAPSLOCK} CAPSLOCK {SCROLLLOCK} SCROLLLOCK {CTRLBREAK} Ctrl+Break {PAUSE} PAUSE {NUMPAD0} - {NUMPAD9} Numpad digits {NUMPADMULT} Numpad Multiply {NUMPADADD} Numpad Add {NUMPADSUB} Numpad Subtract {NUMPADDIV} Numpad Divide {NUMPADDOT} Numpad period {NUMPADENTER} Enter key on the numpad {APPSKEY} Windows App key {LALT} Left ALT key {RALT} Right ALT key {LCTRL} Left CTRL key {RCTRL} Right CTRL key {LSHIFT} Left Shift key {RSHIFT} Right Shift key {SLEEP} Computer SLEEP key
Example
Example of using the first param as numeric to scan for a single VK key
println("Try pressing B or C or Shift+A or Shift+Control+D or Shift+Control+Alt+E"); while(true) { if( RealGetKeyState(@KeyB) ) { println("B is pressed"); } if( RealGetKeyState(@KeyC) ) { println("C is pressed"); } if( RealGetKeyState(@KeyShiftKey) && RealGetKeyState(@KeyA) ) { println("Shift+A is pressed"); } if( RealGetKeyState(@KeyShiftKey) && RealGetKeyState(@KeyControlKey) && RealGetKeyState(@KeyD) ) { println("Shift+Control+D is pressed"); } if( RealGetKeyState(@KeyShiftKey) && RealGetKeyState(@KeyControlKey) && RealGetKeyState(@KeyMenu) && RealGetKeyState(@KeyE) ) { println("Shift+Control+Alt+E is pressed"); } sleep(100); }
Example of using the first param as a string to scan for sequence of keys
while(true) { // Only triggers when SHIFT + NUMLOCK + A are all pressed down if( RealGetKeyState( "+{NUMLOCK}a" ) ) { println("Key sequence was pressed"); } sleep(100); }