libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
KeyEvent Class Reference

Event delivered when a key is pressed or released. More...

#include <keyevent.h>

Inheritance diagram for KeyEvent:
Collaboration diagram for KeyEvent:

Public Types

enum  Key {
  Key_Unknown = 0 , Key_Space = 32 , Key_Escape = 256 , Key_Enter ,
  Key_Tab , Key_Backspace , Key_Insert , Key_Delete ,
  Key_Home , Key_End , Key_PageUp , Key_PageDown ,
  Key_Up , Key_Down , Key_Left , Key_Right ,
  Key_F1 , Key_F2 , Key_F3 , Key_F4 ,
  Key_F5 , Key_F6 , Key_F7 , Key_F8 ,
  Key_F9 , Key_F10 , Key_F11 , Key_F12
}
 Key code enumeration.
 
enum  Modifier : uint8_t {
  NoModifier = 0x00 , ShiftModifier = 0x01 , CtrlModifier = 0x02 , AltModifier = 0x04 ,
  MetaModifier = 0x08
}
 Modifier flags.
 
- Public Types inherited from Event
using Type = uint32_t
 Integer type used to identify event kinds.
 

Public Member Functions

 KeyEvent (Type type, Key key, uint8_t modifiers=NoModifier, const String &text=String())
 Constructs a KeyEvent.
 
Key key () const
 Returns the key code.
 
uint8_t modifiers () const
 Returns the modifier flags.
 
const Stringtext () const
 Returns the printable text.
 
bool isShift () const
 Returns true if the Shift modifier is set.
 
bool isCtrl () const
 Returns true if the Ctrl modifier is set.
 
bool isAlt () const
 Returns true if the Alt modifier is set.
 
bool isMeta () const
 Returns true if the Meta modifier is set.
 
- Public Member Functions inherited from Event
 Event (Type type)
 Constructs an Event with the given type.
 
virtual ~Event ()=default
 Virtual destructor.
 
Type type () const
 Returns the type identifier for this event.
 
bool isAccepted () const
 Returns whether this event has been accepted.
 
void accept ()
 Marks the event as accepted.
 
void ignore ()
 Marks the event as ignored (not accepted).
 

Static Public Member Functions

static String keyName (Key key)
 Returns a human-readable name for the given key code.
 
static String modifierString (uint8_t modifiers)
 Returns a human-readable string for the given modifier flags (e.g. "Ctrl+Shift+").
 
- Static Public Member Functions inherited from Event
static Type registerType ()
 Allocates and returns a unique event type ID.
 

Static Public Attributes

static const Type KeyPress
 Event type ID for KeyEvent.
 
static const Type KeyRelease
 Event type ID for KeyRelease (rarely used in TUI).
 
- Static Public Attributes inherited from Event
static constexpr Type InvalidType = 0
 Sentinel value representing an invalid or unset event type.
 
static const Type Timer
 Event type for TimerEvent.
 
static const Type DeferredCall
 Event type for deferred callable delivery.
 
static const Type SignalEvent
 Event type for cross-thread signal dispatch.
 
static const Type Quit
 Event type requesting an EventLoop to quit.
 

Detailed Description

Event delivered when a key is pressed or released.

Carries a key code, modifier flags, and the printable text for the key press. Registered via Event::registerType().

Constructor & Destructor Documentation

◆ KeyEvent()

KeyEvent::KeyEvent ( Type  type,
Key  key,
uint8_t  modifiers = NoModifier,
const String text = String() 
)
inline

Constructs a KeyEvent.

Parameters
typeThe event type (KeyPress or KeyRelease).
keyThe key code.
modifiersThe modifier flags.
textThe printable text for this key.

The documentation for this class was generated from the following file: