Libraries.Interface.Events.KeyboardEvent Documentation
The KeyboardEvent class represents an event on the keyboard, which is caused by the user pushing down or releasing a key. This class also contains constants for the possible keys that may have been pressed or released.
Inherits from: Libraries.Language.Object
Variables Table
Variables | Description |
---|---|
integer NUM_4 | |
integer UP | |
integer Z | |
integer PAGE_UP | |
integer ALT_LEFT | |
integer UNKNOWN | |
integer INSERT | |
integer NUMPAD_5 | |
integer F7 | |
integer A | |
integer D | |
integer NUMPAD_STAR | |
integer NUMPAD_9 | |
integer NUMPAD_0 | |
integer SPACE | |
integer SCROLL_LOCK | |
integer RELEASED_KEY | The keyCode corresponds to one of the constant values in this class. The default value of 0 is equal to the "UNKNOWN" constant. |
integer ENTER | |
integer P | |
integer L | |
integer M | |
integer PAUSE | |
integer B | |
integer NUM_7 | |
integer NUM_2 | |
integer O | |
integer NUM_1 | |
integer F9 | |
integer F4 | |
integer BACKSPACE | |
integer NUMPAD_4 | |
integer NUMPAD_8 | |
integer SHIFT_RIGHT | |
integer META_LEFT | |
integer NUM_9 | |
integer RIGHT | |
integer APOSTROPHE | |
integer F10 | |
integer NUM_6 | |
integer E | |
integer PAGE_DOWN | |
integer V | |
integer LEFT_BRACKET | |
integer SLASH | |
integer ESCAPE | |
integer NUM_LOCK | |
integer Y | |
integer F12 | This action will return the text value represented by a particular key. The boolean represents whether the text should use the shift-keyed value, e.g., the "A" key on the keyboard can represent the text "a" if shiftPressed is false, or "A" if shiftPressed is true. |
integer GRAVE | |
integer U | |
integer R | |
integer CAPS_LOCK | |
integer NUMPAD_6 | |
integer N | |
integer NUMPAD_MINUS | |
integer CONTROL_RIGHT | |
integer EQUALS | |
integer COLON | |
integer F1 | |
integer NUM_0 | This is either PRESSED_KEY or RELEASED_KEY. |
integer S | |
integer T | |
integer F2 | |
integer DOWN | |
integer NUMPAD_SLASH | |
integer NUM_3 | |
integer COMMA | |
integer H | |
integer NUMPAD_7 | |
integer F11 | |
integer NUM_5 | |
integer F5 | |
integer J | |
integer ALT_RIGHT | |
integer POWER | |
integer X | |
integer END | |
integer pressCount | How many key presses have occurred in a short period of time, including this event (if it is a PRESSED_KEY event). |
integer NUMPAD_3 | |
integer HOME | |
integer eventType | This is either PRESSED_KEY or RELEASED_KEY. |
integer NUMPAD_PLUS | |
integer F8 | |
integer keyCode | The keyCode corresponds to one of the constant values in this class. The default value of 0 is equal to the "UNKNOWN" constant. |
integer F3 | |
integer W | |
integer G | |
integer NUMPAD_1 | |
integer TAB | |
integer F | |
integer F6 | |
integer NUMPAD_EQUALS | |
integer BACKSLASH | |
integer NUMPAD_DECIMAL | |
integer CONTROL_LEFT | |
integer FORWARD_DELETE | |
integer NUMPAD_ENTER | |
integer PRINT_SCREEN | |
integer SEMICOLON | |
integer K | |
integer NUM_8 | |
integer I | |
integer META_RIGHT | |
integer Q | |
integer MINUS | |
integer NUMPAD_2 | |
integer ANY_KEY | How many key presses have occurred in a short period of time, including this event (if it is a PRESSED_KEY event). |
integer LEFT | |
integer PERIOD | |
integer PRESSED_KEY | |
integer CLEAR | |
integer C | |
integer RIGHT_BRACKET | |
integer SHIFT_LEFT |
Actions Documentation
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetPressCount()
This action returns how many times the key described by this event has been recently pressed. The time considered to be "recent" is defined by the ApplicationConfiguration (if keyboard input is relevant to the application type). The value returned includes the key being pressed as part of this event, if the event is a PRESSED_KEY event - e.g., if a key is pressed exactly once, the value returned is 1. If a key is pressed twice in rapid succession, the value returned will be 2.
Return
integer: How many times the key has been recently pressed.
ToText(integer keycode, boolean shiftPressed)
This action will return the text value represented by a particular key. The boolean represents whether the text should use the shift-keyed value, e.g., the "A" key on the keyboard can represent the text "a" if shiftPressed is false, or "A" if shiftPressed is true.
Parameters
- integer keycode: The key code to translate to text.
- boolean shiftPressed: Whether to return the value of the key when shift is pressed, or to return its normal value.
Return
text:
Example
use Libraries.Game.Game
use Libraries.Interface.Events.KeyboardEvent
use Libraries.Interface.Events.KeyboardListener
use Libraries.Game.InputMonitor
class Main is Game, KeyboardListener
InputMonitor monitor
action Main
StartGame()
end
action CreateGame
AddKeyboardListener(me)
end
action PressedKey(KeyboardEvent event)
boolean shift = monitor:IsKeyPressed(event:SHIFT_LEFT) or monitor:IsKeyPressed(event:SHIFT_RIGHT)
text key = event:ToText(event:keyCode, shift)
output "The pressed key was " + key + "."
end
end
ToText(integer keycode)
This action will return the text value represented by a particular key. The returned text value assumes that the shift key is not being held down.
Parameters
- integer keycode: The key code to translate to text.
Return
text:
Example
use Libraries.Game.Game
use Libraries.Interface.Events.KeyboardEvent
use Libraries.Interface.Events.KeyboardListener
class Main is Game, KeyboardListener
action Main
StartGame()
end
action CreateGame
AddKeyboardListener(me)
end
action PressedKey(KeyboardEvent event)
text key = event:ToText(event:keyCode)
output "The pressed key was " + key + "."
end
end
ToTextShift(integer keycode)
This action will return the text value represented by a particular key. The returned text value assumes that the shift key is being held down.
Parameters
- integer keycode: The key code to translate to text.
Return
text:
Example
use Libraries.Game.Game
use Libraries.Interface.Events.KeyboardEvent
use Libraries.Interface.Events.KeyboardListener
class Main is Game, KeyboardListener
action Main
StartGame()
end
action CreateGame
AddKeyboardListener(me)
end
action PressedKey(KeyboardEvent event)
text key = event:ToTextShift(event:keyCode)
output "The pressed key was " + key + "."
end
end