Overview
Dear ImGui uses theImGuiKey enum which contains all possible keyboard, mouse, and gamepad inputs. The keyboard key enum values are named after the keys on a standard US keyboard.
Key State Functions
IsKeyDown
ImGuiKey
Key to check (e.g.,
ImGuiKey_A, ImGuiKey_Space)bool
True if key is currently down
IsKeyPressed
ImGuiKey
Key to check
bool
default:"true"
If true, returns true on key repeat. Repeat rate uses
io.KeyRepeatDelay / io.KeyRepeatRate.bool
True if key was just pressed or repeating
IsKeyReleased
ImGuiKey
Key to check
bool
True if key was just released
GetKeyPressedAmount
ImGuiKey
Key to check
float
Time before repeat starts
float
Repeat rate
int
Number of key presses this frame
Key Chords
IsKeyChordPressed
ImGuiKeyChord
Key chord (e.g.,
ImGuiMod_Ctrl | ImGuiKey_S)bool
True if the key chord was pressed
Consider using
Shortcut() instead, which supports focus routing and is more feature-complete.Key Names
GetKeyName
ImGuiKey
Key to get name for
const char*
Key name string
Keyboard Capture
SetNextFrameWantCaptureKeyboard
io.WantCaptureKeyboard flag next frame. Equivalent to setting io.WantCaptureKeyboard after the next NewFrame() call.
bool
Whether to capture keyboard
ImGuiKey Enum
Keyboard Modifiers
On macOS, Dear ImGui swaps Cmd(Super) and Ctrl keys at the time of
io.AddKeyEvent() call.