API/keyboard: Difference between revisions
Jump to navigation
Jump to search
imported>OCDoc Import Imported from legacy OpenComputers documentation at ocdoc.cil.li |
Clean up Markdown artifacts from DokuWiki migration |
||
| Line 1: | Line 1: | ||
= Keyboard API = | = Keyboard API = | ||
This API allows you to refer to key codes by name, using the | This API allows you to refer to key codes by name, using the <code>keyboard.keys</code> table. This is a two-directional table, for example, the value of <code>keyboard.keys.numpad0</code> is <code>0x52</code>, and the value of <code>keyboard.keys[0x52]</code> is the string <code>numpad0</code>. | ||
Please see [ | Please see [https://github.com/MightyPirates/OpenComputers/blob/master-MC1.7.10/src/main/resources/assets/opencomputers/loot/openos/lib/keyboard.lua the Lua file containing the API's implementation] for the list of available names. | ||
Additionally it registers event listeners to keep track of the state of individual keys. This internal state can be queried using the following functions: | Additionally it registers event listeners to keep track of the state of individual keys. This internal state can be queried using the following functions: | ||
* | * <code>keyboard.isAltDown(): boolean</code> | ||
<pre>Checks if one of the Alt keys is currently being held by some user. | <pre>Checks if one of the Alt keys is currently being held by some user. | ||
</pre> | </pre> | ||
* | * <code>keyboard.isControl(char: number): boolean</code> | ||
<pre>Checks if the specified character (from a keyboard event for example) is a control character as defined by Java's | <pre>Checks if the specified character (from a keyboard event for example) is a control character as defined by Java's Character class. Control characters are usually not printable. | ||
</pre> | </pre> | ||
* | * <code>keyboard.isControlDown(): boolean</code> | ||
<pre>Checks if one of the Control keys is currently being held by some user. | <pre>Checks if one of the Control keys is currently being held by some user. | ||
</pre> | </pre> | ||
* | * <code>keyboard.isKeyDown(charOrCode: any): boolean</code> | ||
<pre>Checks if a specific key is currently being by some user. If a number is specified it is assumed it's a key code. If a string is specified it is assumed it's a single character, such as the ones passed by keyboard events. | <pre>Checks if a specific key is currently being by some user. If a number is specified it is assumed it's a key code. If a string is specified it is assumed it's a single character, such as the ones passed by keyboard events. | ||
</pre> | </pre> | ||
* | * <code>keyboard.isShiftDown(): boolean</code> | ||
<pre>Checks if one of the Shift keys is currently being held by some user. | <pre>Checks if one of the Shift keys is currently being held by some user. | ||
| Line 32: | Line 32: | ||
{{:API/contents}} | {{:API/contents}} | ||
Latest revision as of 20:26, 24 August 2026
Keyboard API
This API allows you to refer to key codes by name, using the keyboard.keys table. This is a two-directional table, for example, the value of keyboard.keys.numpad0 is 0x52, and the value of keyboard.keys[0x52] is the string numpad0.
Please see the Lua file containing the API's implementation for the list of available names.
Additionally it registers event listeners to keep track of the state of individual keys. This internal state can be queried using the following functions:
keyboard.isAltDown(): boolean
Checks if one of the Alt keys is currently being held by some user.
keyboard.isControl(char: number): boolean
Checks if the specified character (from a keyboard event for example) is a control character as defined by Java's Character class. Control characters are usually not printable.
keyboard.isControlDown(): boolean
Checks if one of the Control keys is currently being held by some user.
keyboard.isKeyDown(charOrCode: any): boolean
Checks if a specific key is currently being by some user. If a number is specified it is assumed it's a key code. If a string is specified it is assumed it's a single character, such as the ones passed by keyboard events.
keyboard.isShiftDown(): boolean
Checks if one of the Shift keys is currently being held by some user.
[keyboard]: https://github.com/MightyPirates/OpenComputers/assets/opencomputers/lua/rom/lib/keyboard.lua
Contents
| APIs | |
|---|---|
| OpenOS | buffer - colors - component - computer - event - filesystem - uuid - internet - keyboard - note - process - rc - robot - serialization - shell - sides - term - text - thread - transforms - unicode |
| Lua Libraries | coroutine - package - io - os |