A class providing details for a keyboard event. More...
#include <Wt/WEvent>
Public Member Functions | |
WKeyEvent () | |
Default constructor. | |
Key | key () const |
Returns the key code key that was pressed or released. More... | |
WFlags< KeyboardModifier > | modifiers () const |
Returns keyboard modifiers. More... | |
int | charCode () const |
Returns the unicode character code. More... | |
WString | text () const |
The (unicode) text that this key generated. More... | |
int | keyCode () const |
Returns the raw key code (deprecated). More... | |
bool | altKey () const |
Returns whether the alt key is pressed (deprecated). More... | |
bool | metaKey () const |
Returns whether the meta key is pressed (deprecated). More... | |
bool | ctrlKey () const |
Returns whether the control key is pressed (deprecated). More... | |
bool | shiftKey () const |
Returns whether the shift key is pressed (deprecated). More... | |
A class providing details for a keyboard event.
A key event is associated with the WInteractWidget::keyWentDown(), WInteractWidget::keyWentUp() and WInteractWidget::keyPressed() signals.
bool Wt::WKeyEvent::altKey | ( | ) | const |
Returns whether the alt key is pressed (deprecated).
int Wt::WKeyEvent::charCode | ( | ) | const |
Returns the unicode character code.
This is only defined for a \link WInteractWidget::keyPressed keyPressed \endlink event, and returns the unicode character code point of a character that is entered. For the \link WInteractWidget::keyWentDown keyWentDown \endlink and \link WInteractWidget::keyWentUp keyWentUp \endlink events, '0' is returned. The charCode() may be different from key(). For example, a \link Wt::Key_M Key_M\endlink key may correspond to 'm' or 'M' character, depending on whether the shift key is pressed simultaneously.
bool Wt::WKeyEvent::ctrlKey | ( | ) | const |
Returns whether the control key is pressed (deprecated).
Key Wt::WKeyEvent::key | ( | ) | const |
Returns the key code key that was pressed or released.
The key code corresponds to the actual key on the keyboard, rather than the generated character. All three types of key events provide this information.
int Wt::WKeyEvent::keyCode | ( | ) | const |
Returns the raw key code (deprecated).
bool Wt::WKeyEvent::metaKey | ( | ) | const |
Returns whether the meta key is pressed (deprecated).
WFlags<KeyboardModifier> Wt::WKeyEvent::modifiers | ( | ) | const |
Returns keyboard modifiers.
The result is a logical OR of \link Wt::KeyboardModifier KeyboardModifier\endlink flags. All three types of key events provide this information.
bool Wt::WKeyEvent::shiftKey | ( | ) | const |
Returns whether the shift key is pressed (deprecated).
WString Wt::WKeyEvent::text | ( | ) | const |
The (unicode) text that this key generated.
This is only defined for a \link WInteractWidget::keyPressed keyPressed \endlink event, and returns a string that holds exactly one unicode character, which corresponds to charCode(). For the \link WInteractWidget::keyWentDown keyWentDown \endlink and \link WInteractWidget::keyWentUp keyWentUp \endlink events, an empty string is returned.