JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
KeyboardShortcut Class Reference

Represents a keyboard shortcut, e.g. Ctrl+S More...

#include <jngl/KeyboardShortcut.hpp>

Public Member Functions

 KeyboardShortcut ()
 No shortcut, will never trigger.
 
 KeyboardShortcut (key::KeyType modifier, char key)
 Modifier + key, e.g.
 
 KeyboardShortcut (key::KeyType modifier1, key::KeyType modifier2, char key)
 Two modifiers + key, e.g.
 
 KeyboardShortcut (key::KeyType key)
 Single key, e.g. jngl::key::F1.
 
std::string toString () const
 Used to display the shortcut, e.g.
 
bool pressed () const
 Returns true if all modifiers and the key of the shortcut was pressed in this step.
 

Detailed Description

Represents a keyboard shortcut, e.g. Ctrl+S

Definition at line 14 of file KeyboardShortcut.hpp.

Constructor & Destructor Documentation

◆ KeyboardShortcut() [1/2]

KeyboardShortcut ( key::KeyType modifier,
char key )

Modifier + key, e.g.

{ jngl::key::Control, 's' } for Ctrl+S

Exceptions
std::runtime_errorif modifier is not key::Ctrl, key::Shift or key::Alt

◆ KeyboardShortcut() [2/2]

KeyboardShortcut ( key::KeyType modifier1,
key::KeyType modifier2,
char key )

Two modifiers + key, e.g.

{ jngl::key::Control, jngl::key::Shift, 's' } for Ctrl+Shift+S

Exceptions
std::runtime_errorif modifier is not key::Ctrl, key::Shift or key::Alt or if a modifier is used twice

Member Function Documentation

◆ toString()

std::string toString ( ) const

Used to display the shortcut, e.g.

"Ctrl+Shift+S" or "F3", returns "" for no shortcut

Note
The order of modifiers is always Ctrl, Shift, Alt

◆ pressed()

bool pressed ( ) const

Returns true if all modifiers and the key of the shortcut was pressed in this step.

Note
Won't return true for Ctrl+S if Ctrl+Shift+S or Ctrl+Alt+S was pressed.

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