ifk[-] keycode [toggled] (tab)statements (tab)... [else (tab)statements (tab)...]
Can be single line:
ifk[-](keycode [toggled]) statements [else statements]
keycode - QM key code.
toggled - if nonzero, checks if toggled.
- | not. |
Similar to if.
If the specified key is pressed, executes statements after ifk and skips statements after else (if used). Else skips statements after ifk and executes statements after else (if used).
Not all keys and key combinations give correct result. For example, on some operating systems you cannot test the Pause key.
On Vista/7/8/10, if the active window has higher integrity level (eg QM - standard user, window - administrator), ifk works only with some keys: modifier keys (Ctrl, Shift, Alt, Win), lock keys (CapsLock, NumLock, ScrollLock), Back, Tab, Enter, Esc, and mouse buttons.
On Vista/7/8/10, ifk can reliably check toggled state only for lock keys. The toggled state for other keys is process-specific or thread-specific.
Internally ifk uses QM function RealGetKeyState. You can use it instead of ifk.
QM 2.3.3. Can be used as function. Returns 1 if pressed, 0 if not.
See also: GetMod
ifk(F2) bee ;;if key F2 pressed, beep ifk(K 1) key K ;;if key CapsLock toggled, press CapsLock ifk((1)) bee ;;if left mouse button pressed, beep Repeatedly execute some code; stop when key F12 is pressed rep ... ifk(F12) break RealGetKeyState example if RealGetKeyState(VK_SHIFT) and RealGetKeyState(VK_LBUTTON) out "Pressed Shift key and mouse left button" Can be used as function if(ifk(C) and !ifk(S) and ifk(J 1)) out "Ctrl pressed, Shift not, ScrollLock toggled"