xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

KbdStat()

Determines the state of special keys like Ctrl or Shift keys.

Syntax

KbdStat() --> nKeyState

Return

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
BitKey pressed
1Shift key
3Ctrl key
4Alt key
5Scroll Lock ON
6Num Lock ON
7Caps Lock ON
8Insert ON

Info

Category: CT:Miscellaneous , Keyboard functions , Miscellaneous functions
Source:ct\misc3.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe