Skip to content

raylib.IsKeyPressed

JoeStrout edited this page Oct 23, 2026 · 4 revisions

Check if key has been pressed once

Parameters

Parameter Default Value Note
key

Return value

Condition Return Value
(always) number

Notes

A key counts as "pressed" until the next EndDrawing. On the web, a check placed between EndDrawing and yield never sees the key, so yield right after EndDrawing. See The Main Loop.

Example

raylib.InitWindow 800, 600, "Key Pressed Demo"
count = 0
while not raylib.WindowShouldClose
    if raylib.IsKeyPressed(raylib.KEY_SPACE) then count = count + 1
    raylib.BeginDrawing
    raylib.ClearBackground color.white
    raylib.DrawText "Space presses: " + count, 10, 10, 20, color.black
    raylib.EndDrawing
    yield
end while
raylib.CloseWindow

Clone this wiki locally