scan code problem

Blitz3D Forums/Blitz3D Beginners Area/scan code problem

jvc(Posted 2006) [#1]
hi, i'm new to blitz3d, however i'm having problems with the scancode for Pause and NumLock.

They seem to be strangely reversed when i test my keyboard using just a simple KeyDown() test. The rest
of the keys work fine...

what is wrong here???


mindstorms(Posted 2006) [#2]
You will have to post some code...


Sir Gak(Posted 2006) [#3]
Using the Scancodes Picker under Hekp, I get code 197 for the Pause/Break key, and 69 for the Numlock key, which are the numeric values listed for Scancodes..


jvc(Posted 2006) [#4]
While Not KeyHit(1)

If KeyDown(69) ;num lock
Print "numlock is pressed!"
Else If KeyDown(197) ;break
Print "break is pressed!"
Else
Print "others"
End If

Wend

On my keyboard, if i press numlock i get break, and
if i press break, i get numlock. Is my keyboard mulfunctioning???


Matty(Posted 2006) [#5]
Unusual problem. Is your keyboard in any way 'non standard'? I doubt your keyboard is malfunctioning but it is rather odd that this is occuring.


Sir Gak(Posted 2006) [#6]
to all:
I tried jvc's little test, and I get "break" when I press NumLock. However, I get nothing (ie: "others") when I press Pause|Break.
Just to try a variation on a theme, I rewrote the code as follws:
While Not KeyHit(1)

If KeyHit(69) ;num lock
Print "numlock is pressed!"
EndIf
If KeyDown(197) ;break
Print "break is pressed!"
End If

Wend

Now, I get the symptoms as described by jvc. So, what is going on? I have a generic keyboard, nothing special.

Has anyone else has tried this?


Ross C(Posted 2006) [#7]
I get the same problem here too. Maybe a bug report should be raised?


Sir Gak(Posted 2006) [#8]
Yep, bug report time. jvc, care to do the honors, since you discovered it?


jvc(Posted 2006) [#9]
ok, thanks for the confirmation. bug report sent to support, hope they resolve this fast.


Sir Gak(Posted 2006) [#10]
Oh, BTW, jvc, since you're new to Blitz, welcome!


jfk EO-11110(Posted 2006) [#11]
using scancodes will never give you total security cause the layout is diffrent in various language sets. For example Y and Z are swapped in the german layout. So people usually try pressing Z if "Y for yes" doesn't work.

GetKey() at the other hand returns the correct Ascii number of the keyhit.


jvc(Posted 2006) [#12]
If scancode isnt universal, and not all keys returns ascii values, what is the solution?


Ross C(Posted 2006) [#13]
Don't use keys that could be non-standard i guess... Or, at the option screen, tell the user to press their break/pause key, record the scancode, and use that :o)


jfk EO-11110(Posted 2006) [#14]
Cursor keys and WASD etc. seems to be universal.

For more advanced stuff I'd suggest to add userdefined keyboard mapping, so the user can choose the keys he want's to use.


Sir Gak(Posted 2006) [#15]
When trying to decide what keys to use, remember that at the heart of it, you're creating a user-interface, or UI (GUI, for graphic user interface, as with a mouse, etc). When designing your UI, the goal should be to make it as intuitive as possible. Never, in any program or game I have ever used or even heard of, has there ever been someone using the Pause|Break key, or the NUM LOCK. That's not to say you CAN'T use them, but they are not intuitively going to be guessed by your user.

So, to make a long story short, I agree with Ross C. Try to use standard keys. Good luck with your UI design!