Version 3 Technical Highlights - KBStatus

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 OCT 19923.0+EXPERTKBSTATUS

A function which returns an integer which indicates which special keyboard keys are pressed down at the time that the routine is called. To find out whether a particular key is active it is necessary to BITAND the result with a specific integer as shown in the following table. If the BITAND returns false then the key is not pressed.

1The Right Shift key
2The Left Shift Key
3Left/Right Shift
4The Ctrl Key
8The Alt Key
16The Scroll Lock Key
32The Num Lock Key
64The Caps Lock Key
128Insert Key

Thus to check whether the user was pressing Right-Shifted-Alt the following code segment would suffice

  Declare Function KbStatus
  Loop
    Input X,-1
  Until X = \1B\
    If BitAnd(KbStatus(),1) Then
     If BitAnd(KbStatus(),8) Then
      Print Char(7) :
     End
    End
  Repeat

(Volume 4, Issue 5, Pages 11,12)

  • tips/revmedia/v4i5a6.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1