The (static) Key class (gb. qt4) is used to retrieve information from the keyboard and defines constants for selected keys. Apart from the properties, this class has no methods.
Similar to the class Mouse (→ chapter 14.2), the class Key does not have any events itself, but there are keyboard events that are dealt with in → chapter 14.1.3.
The following table presents selected properties of the Key class:
Property Key. | Description |
---|---|
Alt | Returns True if ALT key is pressed |
Control | Returns True if the Control key has been pressed |
Shift | Returns True if the SHIFT key is pressed |
Normal | Returns True if no special key was pressed |
Meta | Returns True if the Meta or Super key has been pressed |
Code | Returns the code of the key |
Text | Returns the text assigned to the key as a character. |
Table 14.1.1.1.1: Description of selected properties of the 'Key' class
Please note that, for example, the properties Key. Alt, Key. Control, Key. Shift and Key. Normal are always associated with the two events Component_KeyPress or Component_KeyRelease!
Gambas has a set of keyboard constants for certain keys with sufficient self-explanatory names:
F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 Enter Return Left Right Down Up Home End PageUp Insert PageDown Delete BackSpace Space Tab NumLock CapsLock Esc Pause Print
Observe these notes:
'... Dim iKeyValue As Integer ' Syntax: anInteger = Key[ Key As String ] iKeyValue = Key["R"] '...
Die (statische) Klasse Key (gb.qt4) wird zum Abrufen von Informationen über die Tastatur verwendet und definiert Konstanten für ausgewählte Tasten. Neben den Eigenschaften besitzt diese Klasse keine Methoden.
Ähnlich wie die Klasse Mouse (Kapitel 14.2) besitzt die Klasse Key selbst keine Ereignisse, wohl aber existieren Tastatur-Ereignisse, die im Kapitel 14.1.3 behandelt werden.
Es werden in der folgenden Tabelle ausgewählte Eigenschaften der Klasse Key vorgestellt:
Eigenschaft Key. | Beschreibung |
---|---|
Alt | Gibt True zurück, wenn die ALT-Taste gedrückt wurde |
Control | Gibt True zurück, wenn die Control-Taste gedrückt wurde |
Shift | Gibt True zurück, wenn die SHIFT-Taste gedrückt wurde |
Normal | Gibt True zurück, wenn keine Spezial-Taste gedrückt wurde |
Meta | Gibt True zurück, wenn die Meta- oder Super-Taste gedrückt wurde |
Code | Gibt Code der Taste zurück |
Text | Gibt den der Taste zugeordneten Text als ein Zeichen zurück |
Tabelle 14.1.1.1.1: Beschreibung ausgewählter Eigenschaften der Klasse 'Key'
Bitte beachten Sie, dass zum Beispiel die Eigenschaften Key.Alt, Key.Control, Key.Shift und Key.Normal immer in Verbindung mit den beiden Ereignissen Komponente_KeyPress oder Komponente_KeyRelease zu sehen sind!
Gambas verfügt über einen Satz von Tastatur-Konstanten für bestimmte Tasten mit hinreichend selbsterklärender Bezeichnung:
F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 Enter Return Left Right Down Up Home End PageUp Insert PageDown Delete BackSpace Space Tab NumLock CapsLock Esc Pause Print
Beachten Sie diese Hinweise:
'... Dim iKeyValue As Integer ' Syntax: anInteger = Key[ Key As String ] iKeyValue = Key["R"] '...