Scancode to ASCII

Previous topic - Next topic

MrTAToad

Does anyone have a list of scancodes and their ASCII equivelents for Windows, Mac and Linux ?

Moru

Ascii -> Scan code also differs on language so just forget about that and let each user set their own keys for steering :-)

MrTAToad

This is for the GUI.  Unfortunately I will be needing the ASCII equivalent.

Cant use ASCII/CHR$ for reading keypresses because of the iPhone...

Moru

http://en.wikipedia.org/wiki/Keyboard_layout

Then I wish you much fun with it, keyboard layout over scancode is a big can of worms you don't realy want to touch :-)

MrTAToad

Unfortunately it needs to be done :)

Ian Price

Does this help?

Code (glbasic) Select

DIM key$[255]

key$[1]="ESC"
key$[2]="1"
key$[3]="2"
key$[4]="3"
key$[5]="4"
key$[6]="5"
key$[7]="6"
key$[8]="7"
key$[9]="8"
key$[10]="9"
key$[11]="0"
key$[12]="-"
key$[13]="="
key$[14]="BACKSPACE"
key$[15]="TAB"
key$[16]="Q"
key$[17]="W"
key$[18]="E"
key$[19]="R"
key$[20]="T"
key$[21]="Y"
key$[22]="U"
key$[23]="I"
key$[24]="O"
key$[25]="P"
key$[26]="["
key$[27]="]"
key$[28]="ENTER"
key$[29]="LEFT CTRL"
key$[30]="A"
key$[31]="S"
key$[32]="D"
key$[33]="F"
key$[34]="G"
key$[35]="H"
key$[36]="J"
key$[37]="K"
key$[38]="L"
key$[39]=";"
key$[40]="'"
key$[41]="`"
key$[42]="LEFT SHIFT"
key$[43]="#"
key$[44]="Z"
key$[45]="X"
key$[46]="C"
key$[47]="V"
key$[48]="B"
key$[49]="N"
key$[50]="M"
key$[51]=","
key$[52]="."
key$[53]="/"
key$[54]="RIGHT SHIFT"
key$[55]="* NUMPAD"
key$[56]="ALT"
key$[57]="SPACE"
key$[58]="CAPS"
key$[59]="F1"
key$[60]="F2"
key$[61]="F3"
key$[62]="F4"
key$[63]="F5"
key$[64]="F6"
key$[65]="F7"
key$[66]="F8"
key$[67]="F9"
key$[68]="F10"
key$[69]="NUM LOCK NUMPAD"
key$[70]="SCROLL LOCK"
key$[181]="/ NUMPAD"
key$[71]="7 NUMPAD"
key$[72]="8 NUMPAD"
key$[73]="9 NUMPAD"
key$[74]="- NUMPAD"
key$[75]="4 NUMPAD"
key$[76]="5 NUMPAD"
key$[77]="6 NUMPAD"
key$[78]="+ NUMPAD"
key$[79]="1 NUMPAD"
key$[80]="2 NUMPAD"
key$[81]="3 NUMPAD"
key$[82]="0 NUMPAD"
key$[83]="DEL NUMPAD"
key$[86]=" "
key$[87]="F11"
key$[88]="F12"
key$[156]="ENTER NUMPAD"
key$[157]="RIGHT CTRL"
key$[183]="PRINT SCREEN"
key$[184]="ALT GR"
key$[197]="PAUSE BREAK"
key$[199]="HOME"
key$[200]="CURSOR UP"
key$[201]="PAGE UP"
key$[203]="CURSOR LEFT"
key$[205]="CURSOR RIGHT"
key$[208]="CURSOR DOWN"
key$[210]="INSERT"
key$[211]="DELETE"
key$[207]="END"
key$[209]="PAGE DOWN"
key$[210]=" "
key$[211]="?"

// Example for normal keyboard
WHILE TRUE

FOR n=0 TO 255
IF KEY(n) THEN PRINT key$[n],20,20
NEXT

SHOWSCREEN

WEND



It's not every key, as I didn't have a need for every key when I did this.
I came. I saw. I played.

Kitty Hello

uhm... there's Samples/Common/Keydef.gbas
See the function:
keydef_keynames

MrTAToad

Ah, didn't see that, thanks :)

Moru

That one is only valid for an english QWERTY keyboard, doesn't work with swedish, french, german and so on. Not to mention Dworak, sworak & Colemak. :-)

MrTAToad

Thats okay - I dont have a keyboard for those regions :)

Kitty Hello


Moru

#11
And I do. Most people get annoyed when they press the Y button but all they get is Z (but germans should be used to this already, you aren't the first one trying this :-). Or pressing O gives you an S instead. Impossible to write ÅÄÃâ€"ÃÅ"ÛÔß and so on, this is all taken care for you if you directly capture the character instead of scan-codes while typing.

To compare this to english it's like removing the ability to type "e". Sure, you can fake it with "a", it's almost the same shape, just turn it 180 degrees but it's not the same thing and makes reading confusing and slow.

Quote
To compara this to anglish it's lika ramoving tha ability to typa "e". Sura, you can faka it with "a", it's almost tha sama shapa, just turn it 180 dagraas but it's not tha sama thing and makas raading confusing and slow.

MrTAToad

I may try and see if INKEY$ would be viable, because Moru starts frothing at the mouth :)

INKEY$ would solve one problem though - auto-repeating characters should be sorted :)

Moru

Yes, I am a bit aggressive when it comes to my keyboard :-) I was thinking of changing to Sworak several times because my wrists/fingers are getting a bad beating from using the qwerty too much, sworak is supposed to make it easier and I do feel better in the wrists after using that instead. But then I go try and type in some game or application written in USA and then suddenly I can't use sworak any more because they use scancodes to capture keys... is realy annoying and keeps my wrists from getting better. When I complain, the answer I usually get (even from other users) is "I have been using keyboards and mices all my life without any problems so why do you have problems?".