Intrinsic-104 GetScanCode

Top  Previous  Next

104: Result:= GetScanCode(@RawCode, @VirtualCode, @BIOSCode, Wait);


This intrinsic returns low-level Scan Codes from the keyboard. It returns three different codes:


1. Raw Code. This is the true scan code generated by the keyboard hardware. It includes all "state keys" such as Shift, Control, Alt, and the "Win" keys. It also includes Key-Down, Key-Up and Repeat information. A down side to this Raw Code is that it can vary from keyboard to keyboard. Click here for a table of all Raw Scan Codes.


2. Virtual Key Codes. These are translated key codes that are the same for every keyboard. Using these codes will insure that your program will work on any keyboard. The Virtual Key Codes include State Keys like Shift, Control, Alt, and the "Win" keys. Click here for table of all Virtual Key Codes.


3. BIOS Key Codes. This Key Code is identical to the values returned by BIOS Interrupt $16, function 0. It is a two-byte code that contains a Scan Code in the high byte and the normal ASCII value in the low byte. Click here for table of all BIOS Key Codes.


4. Wait. If Wait is true, the program waits until the user presses a key before returning. If Wait is false, the intrinsic will return immediately with information about most recent key press.


5. Result. The returned Result indicates whether a new key has been pressed since the last time this GetScanCode intrinsic was called.


Note: Although EXPL captures most key strokes, some keys are captured by Windows and can't be read. Click here for simple program to test which keys are available on your computer.