-
Declaration:
- Procedure DoneKeyboard;
-
Description:
- DoneKeyboard de-initializes the keyboard interface if the keyboard driver is active. If the
keyboard driver is not active, the function does nothing.
This will cause the keyboard driver to clear up any allocated memory, or restores the console
or terminal the program was running in to its initial state before the call to InitKeyBoard
(299). This function should be called on program exit. Failing to do so may leave the terminal
or console window in an unusable state. Its exact action depends on the platform on which
the program is running.
-
Errors:
- None.
-
See also:
- InitKeyBoard (299)
For an example, see most other functions.
-
Declaration:
- Function FunctionKeyName (KeyCode : Word) : String;
-
Description:
- FunctionKeyName returns a string representation of the function key with code KeyCode.
This can be an actual function key, or one of the cursor movement keys.
-
Errors:
- In case KeyCode does not contain a function code, the SUnknownFunctionKey string is
returned, appended with the KeyCode.
-
See also:
- ShiftStateToString (304) KeyEventToString (300)
Listing: kbdex/ex8.pp
-
Declaration:
- Procedure GetKeyboardDriver (Var Driver : TKeyboardDriver);
-
Description:
- GetKeyBoardDriver returns in Driver the currently active keyboard driver. This function
can be used to enhance an existing keyboarddriver.
For more information on getting and setting the keyboard driver section 11.4, page 313.
-
Errors:
- None.
-
See also:
- SetKeyboardDriver (303)
-
Declaration:
- function GetKeyEvent: TKeyEvent;
-
Description:
- GetKeyEvent returns the last keyevent if one was stored in PendingKeyEvent, or waits for
one if none is available. A non-blocking version is available in PollKeyEvent (301).
The returned key is encoded as a TKeyEvent type variable, and is normally the physical
key scan code, (the scan code is driver dependent) which can be translated with one of the
translation functions TranslateKeyEvent (304) or TranslateKeyEventUniCode (304). See the
types section for a description of how the key is described.
-
Errors:
- If no key became available, 0 is returned.
-
See also:
- PutKeyEvent (302), PollKeyEvent (301), TranslateKeyEvent (304), TranslateKeyEventUniCode
(304)
Listing: kbdex/ex1.pp
-
Declaration:
- function GetKeyEventChar(KeyEvent: TKeyEvent): Char;
-
Description:
- GetKeyEventChar returns the charcode part of the given KeyEvent, if it contains a
translated character key keycode. The charcode is simply the ascii code of the character key
that was pressed.
It returns the null character if the key was not a character key, but e.g. a function key.
-
Errors:
- None.
-
See also:
- GetKeyEventUniCode (299),
GetKeyEventShiftState (298), GetKeyEventFlags (297), GetKeyEventCode (297), GetKeyEvent
(295)
For an example, see GetKeyEvent (295)
-
Declaration:
- function GetKeyEventCode(KeyEvent: TKeyEvent): Word;
-
Description:
- GetKeyEventCode returns the translated function keycode part of the given KeyEvent, if it
contains a translated function key.
If the key pressed was not a function key, the null character is returned.
-
Errors:
- None.
-
See also:
- GetKeyEventUniCode (299), GetKeyEventShiftState (298), GetKeyEventFlags (297),
GetKeyEventChar (296), GetKeyEvent (295)
Listing: kbdex/ex2.pp
-
Declaration:
- function GetKeyEventFlags(KeyEvent: TKeyEvent): Byte;
-
Description:
- GetKeyEventFlags returns the flags part of the given KeyEvent.
-
Errors:
- None.
-
See also:
- GetKeyEventUniCode (299), GetKeyEventShiftState (298), GetKeyEventCode (297),
GetKeyEventChar (296), GetKeyEvent (295)
For an example, see GetKeyEvent (295)
-
Declaration:
- function GetKeyEventShiftState(KeyEvent: TKeyEvent): Byte;
-
Description:
- GetKeyEventShiftState returns the shift-state values of the given KeyEvent. This can be
used to detect which of the modifier keys Shift, Alt or Ctrl were pressed. If none were
pressed, zero is returned.
Note that this function does not always return expected results; In a unix X-Term, the
modifier keys do not always work.
-
Errors:
- None.
-
See also:
- GetKeyEventUniCode (299), GetKeyEventFlags (297), GetKeyEventCode (297),
GetKeyEventChar (296), GetKeyEvent (295)
Listing: kbdex/ex3.pp
-
Declaration:
- function GetKeyEventUniCode(KeyEvent: TKeyEvent): Word;
-
Description:
- GetKeyEventUniCode returns the unicode part of the given KeyEvent if it contains a
translated unicode character.
-
Errors:
- None.
-
See also:
- GetKeyEventShiftState (298), GetKeyEventFlags (297), GetKeyEventCode (297),
GetKeyEventChar (296), GetKeyEvent (295)
No example available yet.
-
Declaration:
- procedure InitKeyboard;
-
Description:
- InitKeyboard initializes the keyboard driver. If the driver is already active, it does nothing.
When the driver is initialized, it will do everything necessary to ensure the functioning of
the keyboard, including allocating memory, initializing the terminal etc.
This function should be called once, before using any of the keyboard functions. When it is
called, the DoneKeyboard (294) function should also be called before exiting the program or
changing the keyboard driver with SetKeyboardDriver (303).
-
Errors:
- None.
-
See also:
- DoneKeyboard (294), SetKeyboardDriver (303)
For an example, see most other functions.
-
Declaration:
- function IsFunctionKey(KeyEvent: TKeyEvent): Boolean;
-
Description:
- IsFunctionKey returns True if the given key event in KeyEvent was a function key or not.
-
Errors:
- None.
-
See also:
- GetKeyEvent (295)
Listing: kbdex/ex7.pp
-
Declaration:
- Function KeyEventToString(KeyEvent : TKeyEvent) : String;
-
Description:
- KeyEventToString translates the key event in KeyEvent to a human-readable description
of the pressed key. It will use the constants described in the constants section to do so.
-
Errors:
- If an unknown key is passed, the scancode is returned, prefixed with the SScanCode string.
-
See also:
- FunctionKeyName (294), ShiftStateToString (304)
For an example, see most other functions.
-
Declaration:
- function PollKeyEvent: TKeyEvent;
-
Description:
- PollKeyEvent checks whether a key event is available, and returns it if one is found. If no
event is pending, it returns 0.
Note that this does not remove the key from the pending keys. The key should still be
retrieved from the pending key events list with the GetKeyEvent (295) function.
-
Errors:
- None.
-
See also:
- PutKeyEvent (302), GetKeyEvent (295)
Listing: kbdex/ex4.pp
-
Declaration:
- function PollShiftStateEvent: TKeyEvent;
-
Description:
- PollShiftStateEvent returns the current shiftstate in a keyevent. This will return 0 if
there is no key event pending.
-
Errors:
- None.
-
See also:
- PollKeyEvent (301), GetKeyEvent (295)
Listing: kbdex/ex6.pp
-
Declaration:
- procedure PutKeyEvent(KeyEvent: TKeyEvent);
-
Description:
- PutKeyEvent adds the given KeyEvent to the input queue. Please note that depending on
the implementation this can hold only one value, i.e. when calling PutKeyEvent multiple
times, only the last pushed key will be remembered.
-
Errors:
- None
-
See also:
- PollKeyEvent (301), GetKeyEvent (295)
Listing: kbdex/ex5.pp
-
Declaration:
- Function SetKeyboardDriver (Const Driver : TKeyboardDriver) : Boolean;
-
Description:
- SetKeyBoardDriver sets the keyboard driver to Driver, if the current keyboard driver is
not yet initialized. If the current keyboard driver is initialized, then SetKeyboardDriver
does nothing. Before setting the driver, the currently active driver should be disabled with
a call to DoneKeyboard (294).
The function returns True if the driver was set, False if not.
For more information on setting the keyboard driver, see section 11.4, page 313.
-
Errors:
- None.
-
See also:
- GetKeyboardDriver (295), DoneKeyboard (294).
-
Declaration:
- Function ShiftStateToString(KeyEvent : TKeyEvent; UseLeftRight : Boolean) :
String;
-
Description:
- ShiftStateToString returns a string description of the shift state of the key event
KeyEvent. This can be an empty string.
The shift state is described using the strings in the SShift constant.
-
Errors:
- None.
-
See also:
- FunctionKeyName (294), KeyEventToString (300)
For an example, see PollShiftStateEvent (301).
-
Declaration:
- function TranslateKeyEvent(KeyEvent: TKeyEvent): TKeyEvent;
-
Description:
- TranslateKeyEvent performs ASCII translation of the KeyEvent. It translates a physical
key to a function key if the key is a function key, and translates the physical key to the
ordinal of the ascii character if there is an equivalent character key.
-
Errors:
- None.
-
See also:
- TranslateKeyEventUniCode (304)
For an example, see GetKeyEvent (295)
-
Declaration:
- function TranslateKeyEventUniCode(KeyEvent: TKeyEvent): TKeyEvent;
-
Description:
- TranslateKeyEventUniCode performs Unicode translation of the KeyEvent. It is not yet
implemented for all platforms.
-
Errors:
- If the function is not yet implemented, then the ErrorCode of the system unit will be set to
errKbdNotImplemented
-
See also:
No example available yet.