Sign in Join
FPDoc Onlineexperiment

keyboard unit

Access to low-level keyboard functions.

The Keyboard unit implements a keyboard access layer which is system independent. It can be used to poll the keyboard state and wait for certain events. Waiting for a keyboard event can be done with the GetKeyEvent function, which will return a driver-dependent key event. This key event can be translated to a interpretable event by the TranslateKeyEvent function. The result of this function can be used in the other event examining functions.

A custom keyboard driver can be installed using the SetKeyboardDriver function. The current keyboard driver can be retrieved using the GetKeyboardDriver function. The last section of this chapter demonstrates how to make a keyboard driver.

Classes and records

TEnhancedKeyEventrecord
TKeyboardDriverrecordKeyboard driver structure.
TKeyRecordrecordKey event decoding type.

Procedures and functions

ConvertEnhancedToLegacyShiftStatefunction
ConvertToLegacyKeyEventfunction
DoneKeyboardprocedureDeactivate keyboard driver.
equal(TEnhancedKeyEvent,TEnhancedKeyEvent):Booleanoperator
FunctionKeyNamefunctionReturn string representation of a function key code.
GetEnhancedKeyEventfunction
GetKeyboardDriverprocedureReturn the current keyboard driver record.
GetKeyEventfunctionGet the next raw key event, wait if needed.
GetKeyEventCharfunctionGet the character key part of a key event.
GetKeyEventCodefunctionTranslate function key part of a key event code.
GetKeyEventFlagsfunctionExtract the flags from a key event.
GetKeyEventShiftStatefunctionReturn the current state of the shift keys.
GetKeyEventUniCodefunctionReturn the Unicode key event.
InitKeyboardprocedureInitialize the keyboard driver.
IsFunctionKeyfunctionCheck whether a given event is a function key event.
KeyEventToStringfunctionReturn a string describing the key event.
KeyPressedfunctionCheck event queue for key press.
PollEnhancedKeyEventfunction
PollKeyEventfunctionGet next key event, but does not wait.
PollShiftStateEventfunctionCheck current shift state.
PutKeyEventprocedurePut a key event in the event queue.
SetKeyboardDriverfunctionSet a new keyboard driver.
ShiftStateToStringfunctionReturn description of key event shift state.
TranslateKeyEventfunctionTranslate raw event to ascii key event.
TranslateKeyEventUniCodefunctionTranslate raw event to UNICode key event.

Types

PTreeElementtypePointer to TTreeElement record.
TEnhancedShiftStateset
TEnhancedShiftStateElementenumeration
TKeyEventtypeBase type to describe all key events.
Tprocedureprocedure typeProcedure prototype.

Constants

AltPrefixconstantKeycode for alternate prefix key for Alt key. Unix Only.
CAPSLOCK_ONconstant
CtrlPrefixconstantKeycode for alternate prefix key for Ctrl key. Unix only.
ENHANCED_KEYconstant
errKbdBaseconstantBase of keyboard routine error reporting constants.
errKbdInitErrorconstantFailed to initialize keyboard driver.
errKbdNotImplementedconstantKeyboard driver not implemented.
kbAltconstantAlt key modifier.
kbASCIIconstantASCII code key event.
kbBackconstant
kbCtrlconstantControl key modifier.
kbdAppsconstantApplication key (popup-menu) pressed.
kbdDeleteconstantDelete key pressed.
kbdDownconstantArrow down key pressed.
kbdEndconstantEnd key pressed.
kbdF1constantF1 function key pressed.
kbdF10constantF10 function key pressed.
kbdF11constantF12 function key pressed.
kbdF12constantF12 function key pressed.
kbdF13constantF13 function key pressed.
kbdF14constantF14 function key pressed.
kbdF15constantF15 function key pressed.
kbdF16constantF16 function key pressed.
kbdF17constantF17 function key pressed.
kbdF18constantF18 function key pressed.
kbdF19constantF19 function key pressed.
kbdF2constantF2 function key pressed.
kbdF20constantF20 function key pressed.
kbdF3constantF3 function key pressed.
kbdF4constantF4 function key pressed.
kbdF5constantF5 function key pressed.
kbdF6constantF6 function key pressed.
kbdF7constantF7 function key pressed.
kbdF8constantF8 function key pressed.
kbdF9constantF9 function key pressed.
kbdHomeconstantHome key pressed.
kbdInsertconstantInsert key pressed.
kbdLeftconstantArrow left key pressed.
kbdLWinconstantLeft windows key pressed.
kbdMiddleconstantMiddle key pad key pressed (numerical 5).
kbdPgDnconstantPage down key pressed.
kbdPgUpconstantPage Up key pressed.
kbdRightconstantArrow right key pressed.
kbdRWinconstantRight windows key pressed.
kbdUpconstantArrow up key pressed.
kbEnterconstant
kbFnKeyconstantfunction key pressed.
kbLeftShiftconstantLeft shift key modifier.
kbPhysconstantPhysical key code event.
kbReleasedconstantKey release event (not implemented in FPC).
kbRightShiftconstantRight shift key modifier.
kbShiftconstantShift key modifier.
kbSpaceBarconstant
kbTabconstant
kbUniCodeconstantUnicode code key event.
LEFT_ALT_PRESSEDconstant
LEFT_CTRL_PRESSEDconstant
NilEnhancedKeyEventconstant
NUMLOCK_ONconstant
RIGHT_ALT_PRESSEDconstant
RIGHT_CTRL_PRESSEDconstant
SAndconstant'And' description string.
SCROLLLOCK_ONconstant
SHIFT_PRESSEDconstant
ShiftPrefixconstantKeycode for alternate prefix key for Shift key. Unix Only.
SKeyPadconstantNames of keypad keys.
SLeftRightconstantNames for left-right keys.
SScanCodeconstantScancode key.
SShiftconstantNames of modifier keys.
SUnicodeCharconstantUnicode character string.
SUnknownFunctionKeyconstantUnknown function key.

Topics

kbddrivertopicWriting a keyboard driver.
kbdscancodetopicKeyboard scan codes.
kbdunixtopicUnix specific notes.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.