ifk[-] keycode [toggled] (tab)statements (tab)... [else (tab)statements (tab)...]
Can be single line:
ifk[-](keycode [toggled]) statements [else statements]
keycode - QM key code. Also can be virtual-key code enclosed in parentheses. Also can be mouse button: (1) left, (2) right, (4) middle, (5) X1, (6) X2.
toggled - if nonzero, checks whether the key is toggled.
| - | not. |
Similar to if.
If the specified key is pressed, executes statements after ifk and skips statements after else (if any). Otherwise, skips statements after ifk and executes statements after else.
Not all keys and key combinations give correct result. For example, on some operating systems you cannot test the Pause key.
On Vista, 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, 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, ScrolLock toggled"