vvavepacket
vvavepacket

Reputation: 1929

What is the win32/system call equivalent of getting the scan code from keyboard?

i have this code in tasm

mov ah,00h
int 21h

cmp ah,3Bh

it works pretty well considering it is a dos based appication (we can see that it uses interrupts which are fairly old). Now the questions is, what is the win32/system call equivalent of getting the scan code from keyboard? Basically, when a user presses the F1 key (scan code is 3Bh), it gets registered in the AH register. How can we implement this in win32 assembly via system calls? (the one with extrn, kernel32 dlls , etc) Im using NASM

Upvotes: 1

Views: 444

Answers (1)

Hans Passant
Hans Passant

Reputation: 942000

For a console mode program, the likeliest home for 32-bit assembly code, it is ReadConsoleInput(). A GUI app gets keystrokes from the WM_KEYDOWN and the WM_CHAR messages, returned by GetMessage(). But of course you'd never write a GUI app in assembly, there's just no point to that.

Calling _getch() from the C runtime library is probably the easiest way to do this, it is a simple function that returns an int.

Upvotes: 1

Related Questions