Scancodes (independant from keyboard type)

BlitzMax Forums/BlitzMax Beginners Area/Scancodes (independant from keyboard type)

Hi!

I have been using b+ for a while and got used to it's scancode system.

There is a feature that i couldn't find on bmax, and i would like to know if it exists at all:

The old b+ scancodes were linked to the position of the key on the keyboard and not on the relative character. This was very handy for me because i am not using english keyboard.

How can i check if a key is down (or has been hit) according to its position on the keyboard and not to the character it represents? (is it possible at all? if not, is there alternative solution as switching to a particular keyboard type at the start of the program?)

Doesn't seem possible, and since Max is cross-platform compatible that's probably why you now have to detect based on the key itself. Maybe Max should know which key is actually which, and you don't need to worry about finding the right button.

Use KeyDown() or KeyHit()
And see the Scancodes section of the modules section of the help.

I actually tried keydown() to test it:

as i have got a QWERTZ keyboard, i tried with

keydown(KEY_Y)

it didnt react as i pressed my "Z" key (i.e. the sixth key of the to row) but did as i pressed my "Y" key (i.e. the first of the third row).

(same using the number keydown(89))

Can you use Getchar?

Best I could tell you is to write a remap function. Something like this.

global UpKey:Int = KEY_W
global DownKey:Int = KEY_S
Global LeftKey:int = KEY_A
Global RightKey:Int = KEY_D

If KeyDown(UpKey) Then MoveUp()
If KeyDown(DownKey) Then MoveDown()
If KeyDown(LeftKey) Then MoveLeft()
If KeyDown(RightKey) Then MoveRight()

...some code, user clicks OPTIONS/REMAP KEYS


Function RemapKeys()
 UpKey = GetNewKey("Press key for moving UP")
 DownKey = GetNewKey("Press key for moving DOWN")
 LeftKey = GetNewKey("Press key for moving LEFT")
 RightKey = GetNewKey("Press Key for moving RIGHT")
End Function

Function GetNewKey:Int(DisplayText:String)
 Cls
 DrawText DisplayText,10,10
 Flip
 Return WaitKey()
End Function


That works.