Class TKeysPressed
Unit
Declaration
type TKeysPressed = class(TObject)
Description
Tracking the "pressed" state of keys. Allows you to query is key (TKey) pressed, and is some character (Char type) pressed.
Hierarchy
- TObject
- TKeysPressed
Overview
Fields
Keys: TKeysBooleans; |
|
Characters: TCharactersBooleans; |
Methods
function Modifiers: TModifierKeys; |
|
procedure KeyDown(const Key: TKey; const KeyString: String); |
|
procedure KeyUp(const Key: TKey; out KeyString: String); |
|
procedure Clear; |
Properties
property Items [const Key: TKey]: boolean read GetItems; |
|
property Strings [const KeyString: String]: Boolean read GetStrings; |
Description
Fields
Keys: TKeysBooleans; |
|
Check is a key (TKey) pressed. This array is read-only from outside of this class! Always Keys[keyNone] = false. |
Characters: TCharactersBooleans; |
|
Check is a character pressed. This array is read-only from outside of this class! Always Characters[#0] = false. Note that since a given character may be generated by various key combinations, this doesn't work as reliably as Keys array. For example, consider pressing a, then shift, then releasing a — for a short time character 'A', and not 'a', should be pressed. Although we do our best (have some mapping tables to track characters), and in practice this works Ok. But still checking for keys on Keys array, when possible, is advised. |
Methods
function Modifiers: TModifierKeys; |
|
Check which modifier keys are pressed. The result it based on current Keys[keyCtrl], Keys[keyShift] etc. values. |
procedure KeyDown(const Key: TKey; const KeyString: String); |
|
Call when key is pressed. Pass TKey, and corresponding character (as String, since it may be UTF-8 character). Pass Key = keyNone if this is not representable as TKey, pass KeyString = '' if this is not representable as String. But never pass both Key = keyNone and KeyString = '' (this would mean that nothing was pressed, as least nothing that can be represented by CGE). |
procedure KeyUp(const Key: TKey; out KeyString: String); |
|
Call when key is released. Never pass Key = keyNone here. It returns which character was released as a consequence of this key release. |
procedure Clear; |
|
Mark all keys as released. That is, this sets all Keys and Characters items to |
Properties
property Items [const Key: TKey]: boolean read GetItems; |
|
Check is a key (TKey) pressed. Returns the same values as are in the Keys table. It's a default property of this class, so you can write e.g. |
Generated by PasDoc 0.16.0-snapshot.