Microsoft KB Archive/38878

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 14:14, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Calling a BIOS Interrupt to Determine the Scan Code of a Key

Article ID: 38878

Article Last Modified on 8/16/2005



APPLIES TO

  • Microsoft Visual Basic for MS-DOS
  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0



This article was previously published under Q38878

SUMMARY

This article includes an example of a CALL INTERRUPT routine that determines the scan code of a key. This program only reports the scan codes for keys that are supported in the ROM BIOS of the machine. Keys such as F11 and F12 do not return scan codes using this interrupt. There are other interrupts that can be used to get the scan codes of extended keys, but they are only supported on machines with extended ROM BIOS. This example program is generic and runs on any PC compatible.

MORE INFORMATION

The interrupt called is "READ STATUS." This is ROM BIOS Interrupt 16h, Function 1h.

Example

' To try this example in VBDOS.EXE:
'  1. From the File menu, choose New Project.
'  2. Copy the code example to the Code window.
'  3. Press F5 to run the program.
'
' To run this program in the environment, you must invoke the
' environment with the /L switch to load the default Quick library:
' VBDOS.EXE /L for Visual Basic 1.0 for MS-DOS
' QB /L QB.QLB for QuickBasic for MS-DOS
'
' Use the following include file for Visual Basic 1.0 for MS-DOS:
REM $INCLUDE: 'VBDOS.BI'
' Use the following include file for QuickBasic for MS-DOS:
REM $INCLUDE: 'QB.BI'
'Use the following include file for Basic PDS for MS-DOS:
REM $INCLUDE: 'QBX.BI'
DIM inregs AS regtype
DIM outregs AS regtype
inregs.ax = &H1         ' Function 1
DO
  CALL INTERRUPT(&H16, inregs, outregs)     ' Call Interrupt 16h
  PRINT "Scan Code is "; outregs.ax \ 256,  ' AH
  PRINT "ASCII is "; outregs.ax AND 255     ' AL
LOOP
END
                


Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00

Keywords: KB38878