DECLARE LIBRARY 'function is already used by QB64 so "User32" is not required
k = GetKey(.15)
'The delay is here so we can slow down how quickly we check for keypresses.
'Set it to 0 and see what happens when you hit a key...
'We read the keyboard state so quickly, we get multiple returns for each press.
IF v2
<> 0 THEN GetKey
= v2: v2
= 0:
EXIT FUNCTION 'return a secondary key for LEFT/RIGHT shift, ctrl CASE 8, 9, 13, 27:
IF GetAsyncKeyState
(i
) THEN v
= i:
EXIT FOR 'backspace, tab, enter, esc CASE 16 TO 18 'shift, ctrl, alt, which we deal with below with the left/right returns CASE 32 TO 40:
IF GetAsyncKeyState
(i
) THEN v
= i:
EXIT FOR 'space, pageup, pagedown, end, home, '37 to 40 left arrow, up arrow, right arrow, down arrow
'It's not a key which QB64 has included on the virtual map listing at https://www.qb64.org/wiki/Keyboard_scancodes
'BEEP
IF GetAsyncKeyState
(i
) THEN PRINT i;
" key pressed, which is not recognized. Please report this to Steve!" 'END
GetKey = v
LastReturn##
= TIMER + Delay##
v2 = 0