# Class: Keyboard

### LuxModule: luxinialuacore

The Keyboard class handles events from the input class of the luxinia core classes. It provides a system for callbackmechanisms and other utility functions.

## Methods:

### Method overview:

- addKeyListener
- enableKeyBinds
- getPressedKeys
- isKeyDown
- keyBindsEnabled
- keycode
- keycode.0
- keycode.1
- keycode.2
- keycode.3
- keycode.4
- keycode.5
- keycode.6
- keycode.7
- keycode.8
- keycode.9
- keycode.:
- keycode.A
- keycode.ALT
- keycode.ALTGR
- keycode.APPEXIT
- keycode.B
- keycode.BACKSPACE
- keycode.C
- keycode.D
- keycode.DEL
- keycode.DOWN
- keycode.E
- keycode.END
- keycode.ENTER
- keycode.ESC
- keycode.F
- keycode.F1
- keycode.F10
- keycode.F11
- keycode.F12
- keycode.F2
- keycode.F3
- keycode.F4
- keycode.F5
- keycode.F6
- keycode.F7
- keycode.F8
- keycode.F9
- keycode.G
- keycode.H
- keycode.HOME
- keycode.I
- keycode.INS
- keycode.J
- keycode.K
- keycode.L
- keycode.LCTRL
- keycode.LEFT
- keycode.LSHIFT
- keycode.M
- keycode.MINUS
- keycode.N
- keycode.NUM0
- keycode.NUM1
- keycode.NUM2
- keycode.NUM3
- keycode.NUM4
- keycode.NUM5
- keycode.NUM6
- keycode.NUM7
- keycode.NUM8
- keycode.NUM9
- keycode.NUMCOMMA
- keycode.NUMDIV
- keycode.NUMENTER
- keycode.NUMMINUS
- keycode.NUMMUL
- keycode.NUMPLUS
- keycode.O
- keycode.P
- keycode.PAGEDOWN
- keycode.PAGEUP
- keycode.PLUS
- keycode.Q
- keycode.R
- keycode.RCTRL
- keycode.RIGHT
- keycode.RSHIFT
- keycode.S
- keycode.SPACE
- keycode.T
- keycode.TAB
- keycode.U
- keycode.UP
- keycode.V
- keycode.W
- keycode.X
- keycode.Y
- keycode.Z
- popKeys
- removeAllKeyBindings
- removeKeyBinding
- removeKeyListener
- setKeyBinding

addKeyListener (KeyListener listener)
  returns: ()
  adds the keylistener to the listener list
enableKeyBinds (on)
  returns: ()
  Enables or disables the keybinding (if console.active()==true, the binding is disabled automaticly). This function is currently used by the GUI, which means that it may not be safe to disable the keybinds in combination with using the GUI.
getPressedKeys ()
  returns: ([table keys,codes])
  returns two tables: One with all pressed keynames and one with the keycode values. This only includes keys that are listed in the keycode table of the Keyboard class. It is also a slow method since it polls every keycode one by one.
isKeyDown (int/string code)
  returns: (boolean isdown)

  this is the same function as input.iskeydown. It is only included here for consistence. This method is insensitive to modifier keys such as SHIFT or ALT. If you poll your keycodes for game actions you should use this method.

  The function accepts either the numerical keycode as used in the Keyboard.keycode table or the nameentry in Keyboard.keycode (i.e. "LSHIFT").

  This function also handles "CTRL" and "SHIFT" as special codes - since the left and right shift / ctrl keys are different keys and must be polled each - however, if you just pass these strings as arguments, the function will return true if either the left or right key is pressed.

  Since 0.93a, this function is case insensitive.
keyBindsEnabled ()
  returns: (on)
  returns enabled state of the keybinding
keycode
  [table] - List of keycode constants
keycode.0
  [int] - 0 key keycode
keycode.1
  [int] - 1 key keycode
keycode.2
  [int] - 2 key keycode
keycode.3
  [int] - 3 key keycode
keycode.4
  [int] - 4 key keycode
keycode.5
  [int] - 5 key keycode
keycode.6
  [int] - 6 key keycode
keycode.7
  [int] - 7 key keycode
keycode.8
  [int] - 8 key keycode
keycode.9
  [int] - 9 key keycode
keycode.:
  [int] - : key keycode
keycode.A
  [int] - a key keycode
keycode.ALT
  [int] - alt key keycode
keycode.ALTGR
  [int] - altgr key keycode
keycode.APPEXIT
  [int] - appexit key keycode
keycode.B
  [int] - b key keycode
keycode.BACKSPACE
  [int] - backspace key keycode
keycode.C
  [int] - c key keycode
keycode.D
  [int] - d key keycode
keycode.DEL
  [int] - del key keycode
keycode.DOWN
  [int] - down key keycode
keycode.E
  [int] - e key keycode
keycode.END
  [int] - end key keycode
keycode.ENTER
  [int] - enter key keycode
keycode.ESC
  [int] - esc key keycode
keycode.F
  [int] - f key keycode
keycode.F1
  [int] - f1 key keycode
keycode.F10
  [int] - f10 key keycode
keycode.F11
  [int] - f11 key keycode
keycode.F12
  [int] - f12 key keycode
keycode.F2
  [int] - f2 key keycode
keycode.F3
  [int] - f3 key keycode
keycode.F4
  [int] - f4 key keycode
keycode.F5
  [int] - f5 key keycode
keycode.F6
  [int] - f6 key keycode
keycode.F7
  [int] - f7 key keycode
keycode.F8
  [int] - f8 key keycode
keycode.F9
  [int] - f9 key keycode
keycode.G
  [int] - g key keycode
keycode.H
  [int] - h key keycode
keycode.HOME
  [int] - home key keycode
keycode.I
  [int] - i key keycode
keycode.INS
  [int] - ins key keycode
keycode.J
  [int] - j key keycode
keycode.K
  [int] - k key keycode
keycode.L
  [int] - l key keycode
keycode.LCTRL
  [int] - lctrl key keycode
keycode.LEFT
  [int] - left key keycode
keycode.LSHIFT
  [int] - lshift key keycode
keycode.M
  [int] - m key keycode
keycode.MINUS
  [int] - minus key keycode
keycode.N
  [int] - n key keycode
keycode.NUM0
  [int] - num0 key keycode
keycode.NUM1
  [int] - num1 key keycode
keycode.NUM2
  [int] - num2 key keycode
keycode.NUM3
  [int] - num3 key keycode
keycode.NUM4
  [int] - num4 key keycode
keycode.NUM5
  [int] - num5 key keycode
keycode.NUM6
  [int] - num6 key keycode
keycode.NUM7
  [int] - num7 key keycode
keycode.NUM8
  [int] - num8 key keycode
keycode.NUM9
  [int] - num9 key keycode
keycode.NUMCOMMA
  [int] - numcomma key keycode
keycode.NUMDIV
  [int] - numdiv key keycode
keycode.NUMENTER
  [int] - numenter key keycode
keycode.NUMMINUS
  [int] - numminus key keycode
keycode.NUMMUL
  [int] - nummul key keycode
keycode.NUMPLUS
  [int] - numplus key keycode
keycode.O
  [int] - o key keycode
keycode.P
  [int] - p key keycode
keycode.PAGEDOWN
  [int] - pagedown key keycode
keycode.PAGEUP
  [int] - pageup key keycode
keycode.PLUS
  [int] - plus key keycode
keycode.Q
  [int] - q key keycode
keycode.R
  [int] - r key keycode
keycode.RCTRL
  [int] - rctrl key keycode
keycode.RIGHT
  [int] - right key keycode
keycode.RSHIFT
  [int] - rshift key keycode
keycode.S
  [int] - s key keycode
keycode.SPACE
  [int] - space key keycode
keycode.T
  [int] - t key keycode
keycode.TAB
  [int] - tab key keycode
keycode.U
  [int] - u key keycode
keycode.UP
  [int] - up key keycode
keycode.V
  [int] - v key keycode
keycode.W
  [int] - w key keycode
keycode.X
  [int] - x key keycode
keycode.Y
  [int] - y key keycode
keycode.Z
  [int] - z key keycode
popKeys
  boolean value - if set to false, no keys are popped (input.popkey) and thus, no keyevents are handled. This function can be used for handling manually popping keys.
removeAllKeyBindings ()
  returns: ()
  removes all keybindings, and defaults APPEXIT key back to system.exit call
removeKeyBinding (int keycode/string keycode)
  returns: ()
  removes keybinding for this key
removeKeyListener (KeyListener listener)
  returns: ()
  removes keylistener from the listener list
setKeyBinding (int/string keycode, [function, [int delay] ])
  returns: ()
  adds keybinding for this key and calls the given function every delay milliseconds while the key is pressed. The keycode can be a string that describes the key same as the keycode names (i.e. "W" or "DEL"). If only a keycode is provided, the keybinding is removed.