API/keyboard

From OpenComputers: Rebooted
Revision as of 08:08, 24 August 2026 by imported>OCDoc Import (Imported from legacy OpenComputers documentation at ocdoc.cil.li)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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](https://github.com/MightyPirates/OpenComputers/blob/master-MC1.7.10/src/main/resources/assets/opencomputers/loot/openos/lib/keyboard.lua) 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 Category Documentation
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