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