This module controls input device.
Enumeration of keys
In starruby, keys will be enumerated as below.
Keyboard
| Enumeration | Common name |
|---|---|
:a - :z | Alphabet |
:d0 - :d9 | Number |
:f1 - :f15 | Function keys |
:numpad0 - :numpad9 | Numpad keys |
:add | + (Numpad) |
:back | BackSpace? |
:capslock | Caps Lock |
:clear | Clear |
:decimal | . (Numpad) |
:delete | Delete |
:divide | / (Numpad) |
:down | Down Arrow |
:help | Help |
:home | Home |
:end | End |
:enter | Enter / Return |
:escape | Esc |
:insert | Insert |
:lcontrolkey | Left Ctrl |
:left | Left Arrow |
:lmenu | Left Alt |
:lshiftkey | Left Shift |
:multiply | * (Numpad) |
:numlock | NumLock? |
:pagedown | Page Down |
:pageup | Page Up |
:rcontrolkey | Left Ctrl |
:right | Right Arrow |
:rmenu | Right Alt |
:rshiftkey | Right Shift |
:scroll | Scroll Lock |
:space | Space |
:subtract | - (Numpad) |
:tab | Tab |
:up | Up Arrow |
Gamepad
| Enumeration | Common name |
|---|---|
:down | Down |
:left | Left |
:right | Right |
:up | Up |
| (Integer) | Buttons correspond to the integer value (start from 1) |
Mouse
| Enumeration | Common name |
|---|---|
:left | Left Button |
:middle | Middle Button |
:right | Right Button |
Module Methods
Input.gamepad_count-
Get number of gamepads connected.
Input.keys(device, options = {})-
Returns array of pushed buttons.
Specify type of device by
deviceValues below can be used.Enumeration Common name :keyboardKeyboard :gamepadGamepad :mouseMouse If no buttons are pushed, return empty array.
As
options, you need to passHash. Keys and values below can be selected.Key Value Default :device_numberDevice number starts from 0. Only valid for gamepads. 0 :durationDuration (unit is frames) of detecting key pushed. -1 means infinity. -1 :delaySet the delay (unit is frames) after the key is pushed. -1 means infinity (no consequent detection). Used for key-repeating. -1 :intervalInterval for detecting the key pushed. Used for key-repeating. 0 (TODO: Insert graph)
Input.mouse_location-
Get an array of mouse position ([(X-Coordinate), (Y-Coordinate)])