Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Scancode -> ASCII

Author
Message
Happy Mongoose
21
Years of Service
User Offline
Joined: 16th Feb 2003
Location: United Kingdom
Posted: 12th May 2003 22:43
Is there any easy way of converting from a scancode to an ASCII character? I ask, because I've heard scancodes can vary from keyboard to keybaord.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2003 00:28
There is a way, but it's not 'easy' and it's not foolproof.



You use it like this:

Richard Davey
Retired Moderator
21
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 13th May 2003 03:04
Alternatively if you're using DBPro then use this inside of your loop:

getkey = asc(entry$())
clear entry buffer

The variable "getkey" will contain the ASCII code of the key pressed. This IS foolproof across different keyboard layouts (French, German, etc) and uses the Windows Message Pump so it'll never miss a keypress either.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2003 20:25
Well, yes, that's another way.

You just have to be sure to run though the loop fast enough to keep entry$() filled with a maximum of 1 character, or keep a buffer to drain a character at a time.

Also, it won't tell you about functions keys, shift, control etc.
Richard Davey
Retired Moderator
21
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 13th May 2003 20:29
Or don't clear the buffer until you're done with it I guess. It will detect function keys, etc, just not via the ASCII command because (naturally) they don't have ASCII values.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2003 20:59
I can only get it to detect the displayable keys, plus tab, backspace and enter.

How would you get it to detect F1 for example?
Happy Mongoose
21
Years of Service
User Offline
Joined: 16th Feb 2003
Location: United Kingdom
Posted: 17th May 2003 23:30
Thanks everyone.



Login to post a reply

Server time is: 2024-04-16 13:59:22
Your offset time is: 2024-04-16 13:59:22