The supplied functions in this snippet can enable you to perform expressions based on the name of a keyboard button, not just its integer code. Whilst a number of keycodes can be calculated, the array lookup approach of these functions enables you to set your own names for the keyboard keys.
I have taken a few functions from my user input library, and will continue to do so in the near future.
//==================================================
Function SetKeyName( sName$, iCode )
KeyNames$( iCode ) = Fast Upper$( sName$ )
Endfunction
//==================================================
Function FindKeyCode( sName$ )
For i = 1 to 255
If KeyNames$(i) = Fast Upper$( sName$ )
ExitFunction i
Endif
Next i
Endfunction 0
//==================================================
Function SetupKeys()
Global Dim KeyNames$(255)
SetKeyName( "0",11 )
SetKeyName( "1",2 )
SetKeyName( "2",3 )
SetKeyName( "3",4 )
SetKeyName( "4",5 )
SetKeyName( "5",6 )
SetKeyName( "6",7 )
SetKeyName( "7",8 )
SetKeyName( "8",9 )
SetKeyName( "9",10 )
SetKeyName( "A",30 )
SetKeyName( "ABNT_C1", 115)
SetKeyName( "ABNT_C2", 126)
SetKeyName( "ADD", 78 )
SetKeyName( "APOSTROPHE",40 )
SetKeyName( "APPS",221 )
SetKeyName( "AT", 145 )
SetKeyName( "AX", 150 )
SetKeyName( "B", 48 )
SetKeyName( "BACK", 14 )
SetKeyName( "BACKSLASH", 43 )
SetKeyName( "BACKSPACE", 14 )
SetKeyName( "C", 46 )
SetKeyName( "CALCULATOR", 161 )
SetKeyName( "CAPITAL", 58)
SetKeyName( "CAPSLOCK", 58)
SetKeyName( "CIRCUMFLEX", 144)
SetKeyName( "COLON", 146)
SetKeyName( "COMMA",51)
SetKeyName( "CONVERT", 121)
SetKeyName( "D", 32)
SetKeyName( "DECIMAL", 83)
SetKeyName( "DELETE", 211)
SetKeyName( "DIVIDE", 181)
SetKeyName( "DOWN",208 )
SetKeyName( "E", 18 )
SetKeyName( "END", 207 )
SetKeyName( "ENTER", 28 )
SetKeyName( "EQUALS", 13 )
SetKeyName( "ESCAPE",1)
SetKeyName( "F", 33)
SetKeyName( "F1", 59)
SetKeyName( "F2", 60)
SetKeyName( "F3", 61)
SetKeyName( "F4", 62)
SetKeyName( "F5", 63)
SetKeyName( "F6", 64)
SetKeyName( "F7", 65)
SetKeyName( "F8", 66)
SetKeyName( "F9", 67)
SetKeyName( "F10", 68)
SetKeyName( "F11", 87)
SetKeyName( "F12", 88)
SetKeyName( "F13", 100)
SetKeyName( "F14", 101)
SetKeyName( "F15", 102)
SetKeyName( "G", 34)
SetKeyName( "GRAVE",41)
SetKeyName( "H", 35)
SetKeyName( "HOME",199)
SetKeyName( "I", 23)
SetKeyName( "INSERT", 210)
SetKeyName( "J", 36)
SetKeyName( "K", 37)
SetKeyName( "KANA",112)
SetKeyName( "KANJI", 148)
SetKeyName( "L", 38)
SetKeyName( "LALT", 56)
SetKeyName( "LBRACKET", 26)
SetKeyName( "LCONTROL", 29)
SetKeyName( "LEFT",203 )
SetKeyName( "LMENU",56)
SetKeyName( "LSHIFT", 42)
SetKeyName( "LWIN",219)
SetKeyName( "M", 50)
SetKeyName( "MAIL",236)
SetKeyName( "MEDIASELECT", 237)
SetKeyName( "MEDIASTOP",164)
SetKeyName( "MINUS",12)
SetKeyName( "MULTIPLY", 55)
SetKeyName( "MUTE",160)
SetKeyName( "MYCOMPUTER", 235)
SetKeyName( "N", 49)
SetKeyName( "NEXT",209)
SetKeyName( "NEXTTRACK",153)
SetKeyName( "NOCONVERT",123)
SetKeyName( "NUMLOCK", 69)
SetKeyName( "NUMPAD0", 82)
SetKeyName( "NUMPAD1", 79)
SetKeyName( "NUMPAD2", 80)
SetKeyName( "NUMPAD3", 81)
SetKeyName( "NUMPAD4", 75)
SetKeyName( "NUMPAD5", 76)
SetKeyName( "NUMPAD6", 77)
SetKeyName( "NUMPAD7", 71)
SetKeyName( "NUMPAD8", 72)
SetKeyName( "NUMPAD9", 73)
SetKeyName( "NUMPADCOMMA", 179)
SetKeyName( "NUMPADENTER", 156)
SetKeyName( "NUMPADEQUALS", 141)
SetKeyName( "NUMPADMINUS", 74)
SetKeyName( "NUMPADPERIOD", 83)
SetKeyName( "NUMPADPLUS",78)
SetKeyName( "NUMPADSLASH", 181)
SetKeyName( "NUMPADSTAR",55)
SetKeyName( "O", 24)
SetKeyName( "OEM_102", 86)
SetKeyName( "P", 25)
SetKeyName( "PAUSE", 197)
SetKeyName( "PERIOD", 52)
SetKeyName( "PGDN",209)
SetKeyName( "PGUP",201)
SetKeyName( "PLAYPAUSE",162)
SetKeyName( "POWER", 222)
SetKeyName( "PREVTRACK",144)
SetKeyName( "PRIOR", 201)
SetKeyName( "Q", 16)
SetKeyName( "R", 19)
SetKeyName( "RALT",184)
SetKeyName( "RBRACKET", 27)
SetKeyName( "RCONTROL", 157)
SetKeyName( "RIGHT", 205 )
SetKeyName( "RMENU", 184)
SetKeyName( "RSHIFT", 54)
SetKeyName( "RWIN",220)
SetKeyName( "S", 31)
SetKeyName( "SCROLL", 70)
SetKeyName( "SEMICOLON", 39)
SetKeyName( "SLASH",53)
SetKeyName( "SLEEP", 223)
SetKeyName( "SPACEBAR", 57)
SetKeyName( "STOP",149)
SetKeyName( "SUBTRACT", 74)
SetKeyName( "SYSRQ", 183)
SetKeyName( "T", 20)
SetKeyName( "TAB", 15)
SetKeyName( "U", 22)
SetKeyName( "UNDERLINE",147)
SetKeyName( "UNLABELED",151)
SetKeyName( "UP", 200)
SetKeyName( "V", 47)
SetKeyName( "VOLUMEDOWN", 174)
SetKeyName( "VOLUMEUP", 176)
SetKeyName( "W", 17)
SetKeyName( "WAKE",227)
SetKeyName( "WEBBACK", 234)
SetKeyName( "WEBFAVORITES", 230)
SetKeyName( "WEBFORWARD", 233)
SetKeyName( "WEBHOME", 178)
SetKeyName( "WEBREFRESH", 231)
SetKeyName( "WEBSEARCH",229)
SetKeyName( "WEBSTOP", 232)
SetKeyName( "X", 45)
SetKeyName( "Y", 21)
SetKeyName( "YEN", 125)
SetKeyName( "Z", 44)
EndFunction