You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keyboard input and event handling for terminal-based applications.
Quick Start
#include<pythonic/TerminalGraphics/Window/Window.hpp>usingnamespacePythonic::TG;while (running)
{
// Check if specific key is pressedif (Keyboard::isKeyPressed(Key::Escape))
running = false;
if (Keyboard::isKeyPressed(Key::Space))
player.jump();
if (Keyboard::isKeyPressed(Key::Left))
player.moveLeft();
if (Keyboard::isKeyPressed(Key::Right))
player.moveRight();
}
Keyboard
Static class for polling keyboard state. Uses non-blocking terminal input.
Method
Description
Example
isKeyPressed(Key)
Check if key is pressed
Keyboard::isKeyPressed(Key::Space)
isKeyPressed(char)
Check if character pressed
Keyboard::isKeyPressed('a')
// Check arrow keysif (Keyboard::isKeyPressed(Key::Up))
velocity.y = -100;
if (Keyboard::isKeyPressed(Key::Down))
velocity.y = 100;
// Check character keysif (Keyboard::isKeyPressed('p'))
togglePause();
// Multiple keys at onceif (Keyboard::isKeyPressed(Key::Left) && Keyboard::isKeyPressed(Key::LShift))
player.sprint(-1);
Key Enum
Keyboard key constants.
Arrow Keys
Key
Description
Key::Up
Up arrow
Key::Down
Down arrow
Key::Left
Left arrow
Key::Right
Right arrow
Special Keys
Key
Description
Key::Escape
Escape key
Key::Space
Spacebar
Key::Enter
Enter/Return
Key::Backspace
Backspace
Key::Tab
Tab key
Key::Delete
Delete key
Key::Insert
Insert key
Key::Home
Home key
Key::End
End key
Key::PageUp
Page Up
Key::PageDown
Page Down
Modifier Keys
Key
Description
Key::LShift
Left Shift
Key::RShift
Right Shift
Key::LControl
Left Control
Key::RControl
Right Control
Key::LAlt
Left Alt
Key::RAlt
Right Alt
Letter Keys
Key
Description
Key::A - Key::Z
Letters A through Z
Number Keys
Key
Description
Key::Num0 - Key::Num9
Top row numbers
Function Keys
Key
Description
Key::F1 - Key::F12
Function keys
One-Shot Input Pattern
For actions that should trigger once per key press (not repeat while held):