Keyboard.is_pressed(key: KeyboardKey) -> Bool
True for exactly one frame on the key-down edge.
if Keyboard.is_pressed(KeyboardKey.SPACE) { -- start game }
Keyboard, mouse, gamepad, touch, gestures, file drop.
Every raylib input binding across the Keyboard, Mouse, Gamepad, Touch, Gestures, and Files (drop) namespaces.
Keyboard.is_pressed(key: KeyboardKey) -> BoolTrue for exactly one frame on the key-down edge.
if Keyboard.is_pressed(KeyboardKey.SPACE) { -- start game }
Keyboard.is_pressed_repeat(key: KeyboardKey) -> BoolTrue on the key-down edge and on OS-driven key-repeat events. Useful for text editing.
if Keyboard.is_pressed_repeat(KeyboardKey.BACKSPACE) { }
Keyboard.is_down / is_released / is_up(key: KeyboardKey) -> Boolis_down: held. is_released: just released (edge). is_up: not held.
if Keyboard.is_down(KeyboardKey.W) { paddle_y = paddle_y - speed }
if Keyboard.is_down(KeyboardKey.S) { paddle_y = paddle_y + speed }
Keyboard.get_pressed() -> KeyboardKeyPops one key from the pressed-queue. Returns KEY_NULL = 0 when queue empty.
val k = Keyboard.get_pressed()
Keyboard.get_char_pressed() -> Int32Pops one Unicode codepoint from the character-queue (respects keyboard layout, shift, IME). Returns 0 when empty.
val c = Keyboard.get_char_pressed()
Keyboard.set_exit_key(key: KeyboardKey)Which key makes Window.should_close() return true (default ESC). Pass KEY_NULL = 0 to disable.
Keyboard.set_exit_key(KeyboardKey.Q)
Mouse.is_button_pressed / is_button_down / is_button_released / is_button_up(button: MouseButton) -> BoolEdge vs held predicates for each MouseButton.
if Mouse.is_button_pressed(MouseButton.LEFT) { -- on click }
Mouse.get_x / get_y / get_position / get_deltaCurrent mouse position in window space; get_delta is the frame-to-frame delta.
val pos = Mouse.get_position()
val d = Mouse.get_delta()
Mouse.set_position(x: Int32, y: Int32) / set_offset(x, y) / set_scale(x, y)Warp cursor; apply coordinate offset / scale (useful when window has letterboxing).
Mouse.set_position(Int32(400), Int32(300))
Mouse.get_wheel_move() -> Float32Vertical wheel delta for this frame. get_wheel_move_v() returns Vector2 for 2D wheels.
zoom = zoom + Mouse.get_wheel_move() * Float32(0.1)
Mouse.set_cursor(cursor: MouseCursor)Change cursor shape. See MouseCursor enum.
Mouse.set_cursor(MouseCursor.CROSSHAIR)
Gamepad.is_available(gamepad: Int32) -> BoolTrue if gamepad at slot gamepad (0-3) is connected.
if Gamepad.is_available(Int32(0)) { }
Gamepad.get_name(gamepad: Int32) -> StringHuman-readable gamepad name from OS/SDL mapping database.
val name = Gamepad.get_name(Int32(0))
Gamepad.is_button_pressed / is_button_down / is_button_released / is_button_up(gamepad, button)Edge + held predicates per gamepad slot and GamepadButton.
if Gamepad.is_button_pressed(Int32(0), GamepadButton.RIGHT_FACE_DOWN) { }
Gamepad.get_button_pressed() -> GamepadButtonPops one button from the pressed-queue. Useful for rebind-UI.
val b = Gamepad.get_button_pressed()
Gamepad.get_axis_count(gamepad) / get_axis_movement(gamepad, axis)Stick / trigger values in [-1, 1] (sticks) or [0, 1] (triggers).
val lx = Gamepad.get_axis_movement(Int32(0), GamepadAxis.LEFT_X)
Gamepad.set_mappings(mappings: String) -> Int32Load SDL_GameControllerDB strings (multiple mappings separated by newlines). Returns count loaded.
Gamepad.set_mappings(db_string)
Gamepad.set_vibration(gamepad, left_motor, right_motor, duration)Rumble both motors at [0..1] intensity for duration seconds.
Gamepad.set_vibration(Int32(0), Float32(1.0), Float32(1.0), Float32(0.25))
Touch.get_x / get_y / get_position(index) / get_point_id(index) / get_point_countMulti-touch state (mobile + touch-enabled desktops). Indexed 0..point_count-1.
val n = Touch.get_point_count()
val p = Touch.get_position(Int32(0))
Gestures.set_enabled(flags: Gesture)Bitmask of Gesture flags to detect (OR multiple).
Gestures.set_enabled(Gesture.TAP)
Gestures.is_detected(gesture: Gesture) -> Bool / Gestures.get_detected() -> GestureQuery if a specific gesture fired this frame, or get the current one.
if Gestures.is_detected(Gesture.SWIPE_RIGHT) { }
Gestures.get_hold_duration / get_drag_vector / get_drag_angle / get_pinch_vector / get_pinch_angleGesture-specific continuous data (hold time in seconds, drag Vector2, angles in radians).
val drag = Gestures.get_drag_vector()
Files.is_dropped() -> BoolTrue if the user dragged-and-dropped one or more files onto the window this frame.
if Files.is_dropped() { -- handle drop }
Files.load_dropped() -> FilePathListGet the dropped paths. Access via FilePathList.get(list, index); remember to Files.unload_dropped(list).
val list = Files.load_dropped()
Files.unload_dropped(list)
Files.unload_dropped(list: FilePathList)Release memory held by Files.load_dropped. Always pair.
Files.unload_dropped(list)
Window.set_exit_key / set_mouse_cursor alternatives.