scan code problem
Blitz3D Forums/Blitz3D Beginners Area/scan code problem
| ||
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??? |
| ||
You will have to post some code... |
| ||
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.. |
| ||
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??? |
| ||
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. |
| ||
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? |
| ||
I get the same problem here too. Maybe a bug report should be raised? |
| ||
Yep, bug report time. jvc, care to do the honors, since you discovered it? |
| ||
ok, thanks for the confirmation. bug report sent to support, hope they resolve this fast. |
| ||
Oh, BTW, jvc, since you're new to Blitz, welcome! |
| ||
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. |
| ||
If scancode isnt universal, and not all keys returns ascii values, what is the solution? |
| ||
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) |
| ||
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. |
| ||
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! |