Difference between revisions of "Keys (API)"
From ComputerCraft Wiki
(New page) |
KnightMiner (Talk | contribs) (added a note about keys.end not working (requiring using keys['end'])) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
The Keys API provides a table of numerical codes corresponding to keyboard keys, suitable for decoding [[Key (event)|key events]]. | The Keys API provides a table of numerical codes corresponding to keyboard keys, suitable for decoding [[Key (event)|key events]]. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | {{API table|Keys|image=Grid disk.png|2= | |
− | + | {{API table/row | |
− | + | |[[keys.getName]]({{Type|number}} code)|{{type|string}} keyName | |
+ | |Translates a numerical key code to a human-readable name. | ||
+ | |odd}} | ||
− | + | }} | |
Although this API contains only one method, it also contains a vast number of constants, one per key, containing the numerical key codes for those keys. As of ComputerCraft 1.52, the following constants are defined: | Although this API contains only one method, it also contains a vast number of constants, one per key, containing the numerical key codes for those keys. As of ComputerCraft 1.52, the following constants are defined: | ||
Line 130: | Line 127: | ||
* insert | * insert | ||
* delete | * delete | ||
+ | |||
+ | Note that when using the "end" key, you will have to write it as <code>keys['end']</code> instead of <code>keys.end</code>, as otherwise it will be detected as the Lua keyword <code>end</code> and cause a script error. | ||
+ | |||
[[Category:APIs]] | [[Category:APIs]] |
Latest revision as of 13:26, 26 August 2015
The Keys API provides a table of numerical codes corresponding to keyboard keys, suitable for decoding key events.
Keys (API) | ||
---|---|---|
Function | Return values | Description |
keys.getName(number code) | string keyName | Translates a numerical key code to a human-readable name. |
Although this API contains only one method, it also contains a vast number of constants, one per key, containing the numerical key codes for those keys. As of ComputerCraft 1.52, the following constants are defined:
- a
- b
- c
- d
- e
- f
- g
- h
- i
- j
- k
- l
- m
- n
- o
- p
- q
- r
- s
- t
- u
- v
- w
- x
- y
- z
- one
- two
- three
- four
- five
- six
- seven
- eight
- nine
- zero
- minus
- equals
- backspace
- tab
- leftBracket
- rightBracket
- enter
- leftCtrl
- semiColon
- apostrophe
- grave
- leftShift
- backslash
- comma
- period
- slash
- rightShift
- multiply
- leftAlt
- space
- capsLock
- f1
- f2
- f3
- f4
- f5
- f6
- f7
- f8
- f9
- f10
- numLock
- scollLock
- numPad7
- numPad8
- numPad9
- numPadSubtract
- numPad4
- numPad5
- numPad6
- numPadAdd
- numPad1
- numPad2
- numPad3
- numPad0
- numPadDecimal
- f11
- f12
- f13
- f14
- f15
- kana
- convert
- noconvert
- yen
- numPadEquals
- cimcumflex
- at
- colon
- underscore
- kanji
- stop
- ax
- numPadEnter
- rightCtrl
- numPadComma
- numPadDivide
- rightAlt
- pause
- home
- up
- pageUp
- left
- right
- end
- down
- pageDown
- insert
- delete
Note that when using the "end" key, you will have to write it as keys['end']
instead of keys.end
, as otherwise it will be detected as the Lua keyword end
and cause a script error.