| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Determines the state of special keys like Ctrl or Shift keys.
KbdStat() --> nKeyState
The function returns a numeric value indicating special keys pressed when the function is called. Each bit of the returned value represents a special key:
Bits set for special keys
| Bit | Key pressed |
|---|---|
| 1 | Shift key |
| 3 | Ctrl key |
| 4 | Alt key |
| 5 | Scroll Lock ON |
| 6 | Num Lock ON |
| 7 | Caps Lock ON |
| 8 | Insert ON |
| Category: | CT:Miscellaneous , Keyboard functions , Miscellaneous functions |
| Source: | ct\misc3.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example displays the result of KbdStat() and
// the individual bits set
#include "Inkey.ch"
PROCEDURE Main()
LOCAL nKey := 0
LOCAL nKbdStat
CLS
SET CURSOR OFF
DO WHILE nKey <> K_ESC
nKey := Inkey(0.1)
IF nKey == K_INS
Set( _SET_INSERT, .NOT. Set( _SET_INSERT ) )
ENDIF
nKbdStat := Kbdstat()
@ 5, 20 SAY "Key state: " + CStr( nKbdStat )
@ 6, 20 SAY " Bits set: " + NToC( nKbdStat, 2, 8, "0" )
@ 7, 20 SAY " 87654321"
ENDDO
RETURN
http://www.xHarbour.com