Page 1 of 1

Keyboard Scan Codes

Posted: Sat Apr 09, 2005 9:29 pm
by Halifax
Im using KeyRight, Left, Up, and Down right now. however, i have searched the internet and this site for the scan codes for other keys like esc etc but i cant get a straight answer.
right now i have this
KeyRight$ = chr$(77) + "P"
(this is quoted from memory, which means its wrong)
so how would i do esc?
KeyEsc$ = chr$(1) '?? that is what qbasic says ESC is... but it doesnt work

Posted: Sat Apr 09, 2005 9:44 pm
by Mitth'raw'nuruodo
inkey$ returns chr$(27) for esc

Posted: Sun Apr 10, 2005 5:03 am
by Z!re
If inkey$ returns a two byte value, it is: chr(null)+chr(scancode)

Otherwise it's chr(asciicode)


Both scancodes and ascii codes can be found in the qb help.

Index->Character Scancodes
Index->Character ASCII Values
(or something)

Posted: Sun Apr 10, 2005 7:07 am
by Mitth'raw'nuruodo
Ya, something like that.
Z!re, I always wanted to ask this:
1. Whats with the first 30 ASCII codes, they don't work.
2. Whats with the Scancodes, they don't work.

Posted: Sun Apr 10, 2005 7:20 am
by {Nathan}
to find a key, just type it while running this program.

Code: Select all

do
a$ = inkey
print src(a$)
loop
then you cana just

Code: Select all

 run this and find you chr value. src is the revverse of char, btw.

Posted: Sun Apr 10, 2005 9:17 am
by Rattrapmax6
^_^, um nathan? you need:

LOCATE 1, 1: PRINT a$

Other wise it will scroll, :wink:

Here, this tut has a list of all the keyboard input codes that you'll probaly ever need::arrow: Basic to Advance keyboard programming :wink:

Posted: Sun Apr 10, 2005 2:55 pm
by Mitth'raw'nuruodo
Better yet:

Code: Select all

DO
 LOCATE 1, 1: PRINT INP(96)
LOOP
That is a better one then INKEY$
Not only do you have a set of numbers for every key on your keyboard (yes including Alt, Ctrl, Shift), But you have 2 sets for eaxh key. 1 set is when the key is pressed down, the other is after it has been released.