I am trying to write a function that is similar to b3d getkey().
I am doing this by getting the keypress and pulling that corresponding number out of an array. I expected the keypress to sync up with a familiar set of scancodes (b3d) but it doesn't. For instance, when I press the "1" key on my keyboard, my function is returning 49. I could certainly manually poll all my keys, and then re-write the array based on what number I am getting per key pressed. However, I am concerned that my keyboard may return differnt interger values per keypress than other peoples keyboards? Is this correct?
teamonkey posts something similar to what I am going for here. but I can not understand everything that is going on there. Also, periods and some punctuation do not work.
Can anyone give me advice on how to more successfully emulate blitz3d's getkey() command?
Thanks!
I am doing this by getting the keypress and pulling that corresponding number out of an array. I expected the keypress to sync up with a familiar set of scancodes (b3d) but it doesn't. For instance, when I press the "1" key on my keyboard, my function is returning 49. I could certainly manually poll all my keys, and then re-write the array based on what number I am getting per key pressed. However, I am concerned that my keyboard may return differnt interger values per keypress than other peoples keyboards? Is this correct?
Graphics 640,480 'Command Console '--------------- Global mychar$ Global mykey% Global vcharacter$[]=[.. "","","1","2","3","4","5","6","7","8","9","0",.. "","","","","Q","W","E","R","T",.. "Y","U","I","O","P","[","]","",.. "","A","S","D","F","G","H","J","K","L",.. ";" , "``","`","","",.. "Z","X","C","V","B","N","M",",",".","/",.. "","*",""," ","",.. "","","","","","","","","","",.. "","","7","8","9","-","4",.. "5","6","+","1","2","3","0",.. ".","/","","","","","","","","","","","","","","","","","","",""] While Not KeyHit(KEY_ESCAPE) mykey% = GetKeyHit%() mychar$ = vcharacter$[mykey%] DrawText "Hit keys and see what happens in the debug output",0,0 If mykey% <> 0 Then Print mychar$ +" = " +mykey% +" ?" EndIf Flip Wend Function GetKeyHit%() For Local i% = 0 To 255 If KeyHit(i) Return i EndIf Next End Function
teamonkey posts something similar to what I am going for here. but I can not understand everything that is going on there. Also, periods and some punctuation do not work.
Can anyone give me advice on how to more successfully emulate blitz3d's getkey() command?
Thanks!