API Reference › Input › Input.key_down
method

Input.key_down

Input.key_down(key) -> bool

Returns whether a physical key is held this frame — from the platform when windowed, from the polled key when headless, and from Input.press injection on any target. Unlike the single-key Input.down, several keys can be held at once (move left and jump). Every key on the keyboard has a code: letters, digits and punctuation are their US-layout character, Space, Enter, Esc, Tab, Backspace, Shift, Ctrl and Alt their usual ones, the arrows 128-131, and the keys that type nothing 132-166 - F1-F12 at 132, Home, End, PageUp, PageDown, Insert and Delete at 144, Caps Lock at 150, the numpad digits at 152 and its *, +, -, . and / at 162. Key.F1, Key.Home and Key.Numpad0 name them.

Example

program Demo {
  entry {
    Input.press('a')
    Input.poll()
    if Input.key_down('a') { print(1) }
  }
}
← All symbols