Wt: Wt::WKeyEvent Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Wt::WKeyEvent Class Reference
Signal/slot system

A class providing details for a keyboard event. More...

`#include <Wt/WEvent>`

List of all members.

## Public Member Functions
| WKeyEvent ()
| Default constructor.
Key | key () const
| Returns the key code key that was pressed or released.
WFlags< KeyboardModifier > | 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 (deprecated).
bool | altKey () const
| Returns whether the alt key is pressed (deprecated).
bool | metaKey () const
| Returns whether the meta key is pressed (deprecated).
bool | ctrlKey () const
| Returns whether the control key is pressed (deprecated).
bool | shiftKey () const
| Returns whether the shift key is pressed (deprecated).

## Detailed Description

A class providing details for a keyboard event.

A key event is associated with the WInteractWidget::keyWentDown(), WInteractWidget::keyWentUp() and WInteractWidget::keyPressed() signals.

## Member Function Documentation

bool Wt::WKeyEvent::altKey | ( |  | ) | const

Returns whether the alt key is pressed (deprecated).

Deprecated:
  Use modifiers() instead.

int Wt::WKeyEvent::charCode | ( |  | ) | const

Returns the unicode character code.

This is only defined for a keyPressed event, and returns the unicode character code point 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.

See also:
  key(), text()

bool Wt::WKeyEvent::ctrlKey | ( |  | ) | const

Returns whether the control key is pressed (deprecated).

Deprecated:
  Use modifiers() instead.

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.

See also:
  modifiers(), charCode()

int Wt::WKeyEvent::keyCode | ( |  | ) | const

Returns the raw key code (deprecated).

Deprecated:
  The value returned is somewhat browser-specific, and it is therefore recommended to use the key() method instead.

See also:
  key()

bool Wt::WKeyEvent::metaKey | ( |  | ) | const

Returns whether the meta key is pressed (deprecated).

Deprecated:
  Use modifiers() instead.

WFlags<KeyboardModifier> Wt::WKeyEvent::modifiers | ( |  | ) | const

Returns keyboard modifiers.

The result is a logical OR of KeyboardModifier flags.

All three types of key events provide this information.

See also:
  key(), charCode()

bool Wt::WKeyEvent::shiftKey | ( |  | ) | const

Returns whether the shift key is pressed (deprecated).

Deprecated:
  Use modifiers() instead.

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.

See also:
  charCode()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator