π¦ JEKeyCode
Technical reference for the
JEKeyCodeclass of JarEngine.
Inherit from
β’>JEInternBaseClass<β’π
πΉ Overview
JEKeyCode is responsible for representing and managing keyboard input codes in JarEngine.
Provides:
- Keyboard key identification and comparison.
- Conversion between internal key codes and integer values.
- Key code grouping through operator overloading.
Represents a keyboard input identifier used by JarEngineβs input system. It allows keyboard keys to be handled as structured objects instead of raw integer values, providing easier comparison, grouping, and debugging capabilities.
πΉ Location
JarEngine
β
βββ events
β βββ JEKeyCode
β
βββ ...
πΉ Data
| Field | Type | Description | Property? | Can be set? |
|---|---|---|---|---|
name |
str |
Human-readable keyboard key name. | True | False |
πΉ API
| Function | Arguments | Returns | Description |
|---|---|---|---|
__init__ |
key: Optional[int] |
Β | Creates a key code object from an optional keyboard key identifier. |
__int__ |
Β | int |
Converts the key code into its integer representation. |
__str__ |
Β | str |
Human-readable key name. |
__or__ |
other: JEKeyCode |
JEKeyCodeGroup |
Creates a key group by combining two key codes. |
__eq__ |
other: JEKeyCode |
JEBool |
Compares two key codes and returns whether they represent the same key. |
__hash__ |
Β | int |
Generates a hash value from the key code for future usage. |
πΉ Usage
from jarengine import Events
jump_key = Events.Keyboard.JEKeyCode(32)
escape_key = Events.Keyboard.JEKeyCode(27)
if jump_key == Events.Keyboard.JEKeyCode(32):
print("Jump key detected")
key_group = jump_key | escape_key