Dark Bit Factory & Gravity
PROGRAMMING => Other languages => Blitz => Topic started by: Paul on April 14, 2007
-
Local i,tmp$;Define out varibles
This is a program to get the scancode and the name of the key pressed, but if i Press a special key like home or ctrl then it doesn't show up correctly. Is there a better way of doing this?
;;;;;;;main loop checkuing for keyhit escape
While Not KeyHit(1)
For i=0 To 256 ;repeat threw all the keys (and maybe to far )
If KeyHit(i) ;find what the keys scancode
tmp$=Chr$(GetKey());get the name of the key
Print i+","+tmp$ ;Print it all on the screen
EndIf
Next
Wend
-
I think the problems with GetKey(). It gets an Ascii code but keys like 'home' wernt around when ascii was invented, so theres no code for them.
-
You could try
if GetKey() = 36
but I wouldn't hold out too much hope. 36 is the Windows scan code for the HOME key.
Jim
-
All the scancodes should be in the help for blitz:
Scancodes
KEYBOARD KEY SCANCODE COMMENTS
ESCAPE 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
0 11
Minus (-) 12 On Main Keyboard
Equals (=) 13
Backspace 14 Backspace key
Tab 15
Q 16
W 17
E 18
R 19
T 20
Y 21
U 22
I 23
O 24
P 25
Left Bracket ([) 26
Right Bracket (]) 27
Return/Enter 28 Return/Enter on Main Keyboard
Left Control 29
A 30
S 31
D 32
F 33
G 34
H 35
J 36
K 37
L 38
Semi-Colon (;) 39
Apostrophe (') 40
Grave 41 Accent Grave
Left Shift 42
Backslash (\) 43
Z 44
X 45
C 46
V 47
B 48
N 49
M 50
Comma (,) 51
Period (.) 52 On Main keyboard
Slash (/) 53 On Main Keyboard
Right Shift 54
Multiply (*) 55 On Numeric Keypad
Left Alt/Menu 56
Space 57
Capital 58
F1 59
F2 60
F3 61
F4 62
F5 63
F6 64
F7 65
F8 66
F9 67
F10 68
NumLock 69
Scroll Lock 70
NumPad 7 71
NumPad 8 72
NumPad 9 73
Subtract (-) 74 On Numeric Keypad
NumPad 4 75
NumPad 5 76
NumPad 6 77
Add (+) 78 On Numeric Keypad
NumPad 1 79
NumPad 2 80
NumPad 3 81
NumPad 0 82
Decimal (.) 83 On Numeric Keypad
OEM_102 86 On UK/Germany Keyboards
F11 87
F12 88
F13 100 (NEC PC98)
F14 101 (NEC PC98)
F15 102 (NEC PC98)
Kana 112 Japanese Keyboard
ABNT_C1 115 /? on Portugese (Brazilian) keyboards
Convert 121 Japanese Keyboard
NoConvert 123 Japanese Keyboard
Yen 125 Japanese Keyboard
ABNT_C2 126 Numpad . on Portugese (Brazilian) keyboards
Equals 141 = on numeric keypad (NEC PC98)
PrevTrack 144 Previous Track (DIK_CIRCUMFLEX on Japanese keyboard)
AT 145 (NEC PC98)
Colon (:) 146 (NEC PC98)
Underline 147 (NEC PC98)
Kanji 148 Japanese Keyboard
Stop 149 (NEC PC98)
AX 150 Japan AX
Unlabeled 151 (J3100)
Next Track 153 Next Track
Enter 156 ENTER on Numeric Keypad
Right Control 157
Mute 160 Mute
Calculator 161 Calculator
Play/Pause 162 Play/Pause
Media Stop 164 Media Stop
Volume Down 174 Volume -
Volume Up 176 Volume +
Web Home 178 Web Home
Comma (,) 179 On Numeric Keypad (NEX PC98)
Divide (/) 181 On Numeric Keypad
SysReq 183
Right Alt/Menu 184 Right Alt
Pause 197 Pause
Home 199 Home on Arrow Pad
Up 200 Up Arrow on Arrow Keypad
Page Up/Prior 201 Page Up on Arrow Keypad
Left 203 Left Arrow on Arrow Keypad
Right 205 Right Arrow on Arrow Keypad
End 207 End Key on Arrow Keypad
Down 208 Down Key on Arrow Keypad
Next 209 Next Key on Arrow Keypad
Insert 210 Insert Key on Arrow Keypad
Delete 211 Delete Key on Arrow Keypad
Left Windows 219 Left Windows Key
Right Windows 220 Right Windows Key
Apps 221 Apps Menu Key
Power 222 System Power
Sleep 223 System Sleep
Wake 227 System Wake
Web Search 229
Web Favorites 230
Web Refresh 231
Web Stop 232
Web Forward 233
Web Back 234
My Computer 235
Mail 236
Media Select 237
The above is taken from the blitzplus help, but its the same for blitz3d and I am sure the same in the old blitz2d. I hope it helps somewhat.
-
This is what I've some up with and I hope it works on other countries keyboards :)
Im trying to use the getkey as often as posible because i think that the scancodes have a bigger risk of Geting the wrong name.
Dim keys$(255)
keys$(1)="Home"
keys$(2)="End"
keys$(3)="Insert"
keys$(4)="Delete"
keys$(5)="PageUp"
keys$(6)="PageDown"
keys$(9)="Tab"
Dim keys2$(255)
keys2(1)="Esc"
keys2(29)="Left Ctrl"
keys2(157)="Right Ctrl"
keys2(42)="Left Shift"
keys2(54)="Right Shift"
keys2(58)="Caps lock"
keys2(56)="Alt"
keys2(184)="Alt Gr"
keys2(57)="Space"
keys2(14)="BackSpace"
For i=59 To 68
keys2(i)="F"+(i-58)
Next
keys2(87)="F11"
keys2(88)="F12"
keys2(70)="ScrollLock"
keys2(69)="Pause/Brea