KEYBOARDVALUE

Synopsis
KEYBOARDVALUE
Description

Outputs a number that corresponds to last key that was either pushed or released. The number which it outputs depends on both the key that was pressed and whether KEYBOARDON was given one or two inputs.

If KEYBOARDON was given one input, then the keyboard input is captured as the character that was typed. That is, KEYBOARDVALUE outputs the ASCII value of last character that was typed. For example, on a US keyboard, "5" and "%" are both painted on the same key. If user hits the '5' key without a Shift, then KEYBOARDVALUE outputs 53, which is ASCII 5. On the other hand, if the user hits the '5' key while holding the Shift key down, then KEYBOARDVALUE outputs 37, which is ASCII "%.

Furthermore, if KEYBOARDON was only given one input, then keystrokes that are not directly related to textual characters are ignored. For example, the Shift, Ctrl, Home, and End keys are ignored.

If KEYBOARDON was given two inputs, then KEYBOARDVALUE outputs the keystrokes as distinct physcial keys on the keyboard, but not necessarily the intended character. In this case, when the 5 key is pressed, KEYBOARDVALUE outputs the same number regardless of whether Shift was being held at the time. However, there are distinct events when the Shift key is pressed and when it is released, so you can still identify the difference between a 5 and a %.

In general, if KEYBOARDON was given two inputs, then each physical key generates a unique number, but there are exceptions. The number that is assigned to some keys may vary across keyboards and keyboard layouts (for example, US or French). Similarly, some keyboards (such as the Microsoft Natural Keyboard or the Microsoft Comfort Keyboard) have more keys than a normal keyboard and can generate keyboard events that cannot be generated on other keyboards (such as a "Left Shift" as distict from a "Right Shift", or a "Volume Up" key). Finally, some small keyboards, such as those on a laptop, have special modes where the same physical key might act as two distinct keys depending on the keyboard's mode. For example, the J key might act as a Num Pad 1 when a special "alternate mode" key is held down. The KEYBOARDVALUE assignments shown in the table below should be portable across all keyboards.

KeyKEYBOARDVALUE
Backspace8
Tab9
Clear12
Enter13
Shift16
Ctrl17
Alt18
Pause19
Caps Lock20
Esc27
Spacebar32
Page Up33
Page Down34
End35
Home36
Left Arrow37
Up Arrow38
Right Arrow39
Down Arrow40
Print Screen44
Insert45
Delete46
0 Key48
1 Key49
2 Key50
3 Key51
4 Key52
5 Key53
6 Key54
7 Key55
8 Key56
9 Key57
A Key65
B Key66
C Key67
D Key68
E Key69
F Key70
G Key71
H Key72
I Key73
J Key74
K Key75
L Key76
M Key77
N Key78
O Key79
P Key80
Q Key81
R Key82
S Key83
T Key84
U Key85
V Key86
W Key87
X Key88
Y Key89
Z Key90
Left Windows Key91
Right Windows Key92
Applications Key93
0 Key on Num Pad96
1 Key on Num Pad97
2 Key on Num Pad98
3 Key on Num Pad99
4 Key on Num Pad100
5 Key on Num Pad101
6 Key on Num Pad102
7 Key on Num Pad103
8 Key on Num Pad104
9 Key on Num Pad105
* Key on Num Pad106
+ Key on Num Pad107
- Key on Num Pad109
. Key on Num Pad (decimal separator)110
/ Key on Num Pad111
F1112
F2113
F3114
F4115
F5116
F6117
F7118
F8119
F9120
F10121
F11122
F12123
Num Lock144
Scroll Lock145
Volume Mute173
Volume Down174
Volume Up175
+ Key187
, Key188
- Key189
. Key190

The following KEYBOARDVALUE assignments should be portable across all keyboards with a standard US layout.

KeyKEYBOARDVALUE
; or :186
/ or ?191
` or ~192
[ or {219
\ or |220
} or ]221
' or "222

Example
KEYBOARDON [PRINT CHAR KEYBOARDVALUE]
FULLSCREEN
SETFOCUS [FMSLogo]

Press the 'A' key on the keyboard
a
Press the 'B' key on the keyboard
b

KEYBOARDOFF
SPLITSCREEN

SourceForge.net Logo