Jump to content

Keyboard input/Keypress check: Difference between revisions

(added MiniScript example)
Line 431:
<lang AutoHotkey>; KeyIsDown := GetKeyState("KeyName" [, "Mode"])
State := GetKeyState("RButton", "P") ; Right mouse button. P = Physical state.</lang>
=={{header|AWK}}==
<lang AWK>
# syntax: TAWK -f KEYBOARD_INPUT_KEYPRESS_CHECK.AWK
BEGIN {
arr["\b"] = "BACKSPACE"
arr["\t"] = "TAB"
arr["\x0D"] = "ENTER"
printf("%s Press any key; ESC to exit\n",ctime())
while (1) {
nkeys++
key = getkey()
if (key in arr) { key = arr[key] }
space = ((length(key) > 1 && nkeys > 1) || length(p_key) > 1) ? " " : ""
keys = keys space key
if (key == "ESC") { break }
p_key = key
}
printf("%s %d keys were pressed\n",ctime(),nkeys)
printf("%s\n",keys)
exit(0)
}
</lang>
{{out}}
<pre>
Mon Dec 30 14:03:57 2019 Press any key; ESC to exit
Mon Dec 30 14:04:03 2019 12 keys were pressed
hello world ESC
</pre>
 
=={{header|Axe}}==
477

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.