GLBasic User Manual

Main sections

KEY()

a%=KEY(code%)



Returns 1 if the key corresponding to key-code code% is currently pressed, otherwise it returns 0.

All keys have a key-code assigned to them (e.g. the tab key is assigned code 15, key 'b' is assigned code 48).
To find out what the key-code is for a certain key, use the program 'Keycode.exe' in the Tools folder.

Note : This command does not work for Console applications. Use INKEY, KEYWAIT or INPUT instead.

On a SmartPhone/PocketPC these keys are mapped to the PC-keyboard:
// D-Pad (any device)
Key PC-Key
--------------
<- 203 Cursors
-> 205
^ 200
V 208
o 28 Return

// Application_Buttons (PocketPC)

Key iPAQ3600 PC-Key
----------------------
199 calendar home
207 mail end
210 Q insert
211 -> del
157,29 audiorec ctrl


Num-Pad (Smartphone)

SMPH | Key
-------+--------------------
| PC-NUMPAD PC-Main
1 2 3 | 71 72 73 2 3 4 (Number keys)
4 5 6 | 75 76 77 5 6 7
7 8 9 | 79 80 81 8 9 10
* 0 # | 55 81 83 27 11 43 ( ] 0 \ )

SMPH Key PC-Key
-----------------
dial 211 del
hangup 207 end
home 199 home
back 1 esc


Application Buttons - SmartPhone

SMPH Key PC-Key
---------------
(@t) 67 F9
prev 68 F10
play 87 F11
next 88 F12

Application Buttons - GP2X

GP2X Key(s) PC-Key
--------------------------------------------
DPad 203,205,200,208,57 Cursor Keys/Space
Volume 201,209 PageDn/PageUp
Shoulder 42, 54 LShift/RShift
Start 28 Enter
Select 15 Tab
A,B,X,Y 44,45,29,58 A,D,S,W
30,32,31,17 Y,X,LCtr,CapsLock
Vol +&- 01 ESC




Sample:
 
// End with ESC
WHILE TRUE // Endless-Loop
IF KEY(57) = 1; PRINT "Space Bar is Pressed", 100, 100; ENDIF
SHOWSCREEN
WEND

See also...