Home
Site Structure

Programming Home
  Basic Home
    GUI & OS Home
    QB Knowledge Base
    Professor Answers
    Codename Surena
    QB Downloads

Write Us

Special Links
QB DirectoryNEW

Codename Surena
Forums
Sepent Basic GUI & OS Home
Register Log In

How to get/set two-state keys status?
Bytes number &H417 and &H418 in segment 0 represents the status of these keys as follows:

Bit/Byte &H417 &H418
0 Right shift key pressed/not pressed -
1 Left shift key pressed/not pressed -
2 Control(Ctrl) key pressed/not pressed -
3 Alternate(Alt) key pressed/not pressed -
4 Scroll Lock key On/Off Scroll Lock key pressed/not pressed
5 Num Lock key On/Off Num Lock key pressed/not pressed
6 Caps Lock key On/Off Caps Lock key pressed/not pressed
7 Insert key On/Off Insert key pressed/not pressed

You can use POKE and PEEK to get or set the state of two-state keys. If you want to check the state of the keys you should check the bit shown in the table for that key. For example, to check the state of CAPS LOCK key:

	DEF SEG = 0
	IF PEEK(&H417) AND &H40 THEN
		'CAPS LOCK is on.
	END IF
		

And to turn on CAPS LOCK:

	DEF SEG = 0
	POKE &H417, PEEK(&H417) OR &H40
		

For more information on setting and getting bits within a number, see ht4:How to get/set a bit within a binary number?

NOTE: The instructions in this article only work correctly on IBM PC, XT and AT computers.