Intrinsic-98 GetKeyState

Top  Previous  Next

98: State:= GetKeyState(Key);

 

This intrinsic returns the state of the specified key. If the key is currently down, bit zero, the least significant bit is set. If the key was pressed since last time this intrinsic was called, bit one is set. For example:

 

       State:= GetKeyState(LeftAltKey);

 

If State & 1 then AltKeyDown;

If State & 2 then AltWasPressed;

 

Note: Key values like ShiftKey and ControlKey do not return information about whether they have been pressed and released. This is because a key code like ShiftKey is not tied to one specific key, so it can correspond to either the right or left key being pressed. It you want press-release information about shift keys, you must choose a specific key such as LeftShifKey.

 

The Key value is specified by the constants described below.

 

Mouse Buttons

LeftMouse = 1

RightMouse = 2

MiddleMouse = 4






ASCII Characters

BackSpaceKey = 8

TabKey = 9

ClearKey = 12

ReturnKey = 13

EscapeKey = 27

SpaceKey = 32



Num0Key=$30

Num1Key=$31

Num2Key=$32

Num3Key=$33

Num4Key=$34

Num5Key=$35

Num6Key=$36

Num7Key=$37

Num8Key=$38

Num2Key=$38

CharAKey=$41

CharBKey=$42

CharCKey=$43

CharDKey=$44

CharEKey=$45

CharFKey=$46

CharGKey=$47

CharHKey=$48

CharIKey=$49

CharJKey=$4A

CharKKey=$4B

CharLKey=$4C

CharMKey=$4D

CharNKey=$4E

CharOKey=$4F

CharPKey=$50

CharQKey=$51

CharRKey=$52

CharSKey=$53

CharTKey=$54

CharUKey=$55

CharVKey=$56

CharWKey=$57

CharXKey=$58

CharYKey=$59

CharZKey=$5A

Cursor Movement

PageUpKey = 33

PageDownKey = 34

EndKey = 35

HomeKey = 36

LeftArrowKey = 37

UpArrowKey = 38

RightArrowKey = 39

DownArrowKey = 40

Commands

SelectKey = 41

PrintKey = 42

InsertKey = 45

DeleteKey = 46

HelpKey = 47

 

 

 

Control, Shift, Alt, etc.

ShiftKey = 16

ControlKey = 17

MenuKey = 18

PauseKey = 19

CapLockKey = 20

LeftshiftKey = 160

RightShiftKey = 161

LeftControlKey = 162

RightControlKey = 163

LeftAltKey = 164

RightAltKey = 165

NumlockKey = 144

ScrollKey = 145

LeftWinKey = 91

RightWinKey = 92

AppsKey = 93

ControlBreakKey = 3








Function Keys

F1Key = 112

F2Key = 113

F3Key = 114

F4Key = 115

F5Key = 116

F6Key = 117

F7Key = 118

F8Key = 119

F9Key = 120

F10Key = 121

F11Key = 122

F12Key = 123

F13Key = 124

F14Key = 125

F15Key = 126

F16Key = 127

F17Key = 128

F18Key = 129

F19Key = 130

F20Key = 131

F21Key = 132

F22Key = 133

F23Key = 134

F24Key = 135

Numeric Key Pad

NumPad0Key = 96

NumPad1Key = 97

NumPad2key = 98

NumPad3Key = 99

NumPad4Key = 100

NumPad5Key = 101

NumPad6Key = 102

NumPad7Key = 103

NumPad8Key = 104

NumPad9Key = 105

MultiplyKey = 106

AddKey = 107

SeparatorKey = 108

SubtractKey = 109

DecimalKey = 110

DivideKey = 111