INKEY$ will return those keystrokes as single byte ASCII values:
----------
'public domain
DIM k AS STRING
CLS
DO
DO
k = INKEY$
LOOP UNTIL LEN(k)
IF LEN(k) = 1 THEN
PRINT "chr$(&h"; HEX$(ASC(k)); ")"
ELSE
PRINT "mki$(&h"; HEX$(CVI(k)); ")"
END IF
LOOP UNTIL k = CHR$(&H1B)
SYSTEM
----------
You will notice that ctrl+a is ASCII 0x1, ctrl+b is 0x2, ctrl+c is 0x3, etc. They are in alphabetical order.
If you really need scan codes:
----------
;public domain, june 2011, michael calkins
;nasm -o scancode.com scancode.asm
cpu 386
org 0x100
std
mov dx,_initmsg
mov ah,0x9
int 0x21
_mainloop:
xor ah,ah
int 0x16
mov dx,ax
mov bx,ax
mov di,_buf
mov cx,0x4
.lp:
mov al,dl
and al,0xf
cmp al,0xa
jb .skip
add al,0x27
.skip:
add al,0x30
stosb
shr dx,0x4
loop .lp
mov dx,_msg
mov ah,0x9
int 0x21
cmp bl,0x1b
jnz _mainloop
xor ah,ah
int 0x21
_initmsg:
db "ESC to exit. High byte is scan code, low byte is ASCII value.",0xd,0xa,"$"
_msg:
db "0x",0x0,0x0,0x0
_buf:
db 0x0,0xd,0xa,"$"
----------
You will see that the scan codes (high byte) start at 0x10 for "q" and go up in qwerty order. The CTRL doesn't make a difference for the scan code. You can see that the virtual scan codes in Windows are the same, at least for those keystrokes:
http://www.network54.com/Forum/632471/message/1297566746/
You'll find the other files (t.c, m.bat) to build that program in:
http://www.network54.com/Forum/632471/message/1297290043/
Regards,
Michael |