scim::KeyEvent Struct Reference
Accessories

The class to store a keyboard event. More...

`#include <scim_event.h>`

## Public Member Functions

| KeyEvent (uint32 c=0, uint16 m=0, uint16 l=0)
| Default constructor.
| KeyEvent (const String &str)
| Constructor, construct a key event from a string.
bool | empty () const
| Check if this KeyEvent is empty.
char | get_ascii_code () const
| Get the ascii code of this key event.
ucs4_t | get_unicode_code () const
| Get the Unicode code of this key event.
String | get_key_string () const
| Get the string of this key event.
KeyEvent | map_to_layout (KeyboardLayout new_layout) const
| Map this KeyEvent to another Keyboard Layout.
bool | is_shift_down () const
| Check if the Shift key is pressed down.
bool | is_caps_lock_down () const
| Check if the CapsLock key is pressed down.
bool | is_control_down () const
| Check if the Ctrl key is pressed down.
bool | is_alt_down () const
| Check if the Alt key is pressed down.
bool | is_meta_down () const
| Check if the Meta key is pressed down.
bool | is_super_down () const
| Check if the Super key is pressed down.
bool | is_hyper_down () const
| Check if the Hyper key is pressed down.
bool | is_num_lock_down () const
| Check if the num lock key is pressed down.
bool | is_key_press () const
| Check if it's a key press event.
bool | is_key_release () const
| Check if it's a key release event.
bool | operator== (const KeyEvent &key) const
| Compare two key events.
bool | operator!= (const KeyEvent &key) const
| Compare two key events.
bool | operator< (const KeyEvent &key) const
| Compare two key events.
bool | is_lock_down () const
| Check if the lock key is pressed down.
bool | is_mod1_down () const
| Check if the mod1 key is pressed down.
bool | is_mod2_down () const
| Check if the mod2 key is pressed down.
bool | is_mod3_down () const
| Check if the mod3 key is pressed down.
bool | is_mod4_down () const
| Check if the mod4 key is pressed down.
bool | is_mod5_down () const
| Check if the mod5 key is pressed down.
bool | is_scroll_lock_down () const
| Check if the scroll lock key is pressed down.

## Public Attributes

uint32 | code
uint16 | mask
uint16 | layout

## Detailed Description

The class to store a keyboard event.

A keyboard event contains a key code and a set of key masks. The key masks indicate which modifier keys are pressed down and if it's a key release event.

It also contains the Keyboard Layout information. IMEngines can map a KeyEvent to another layout by calling method map_to_layout().

## Constructor & Destructor Documentation

## KeyEvent() [1/2]

scim::KeyEvent::KeyEvent | ( | uint32 | c = 0,
|  | uint16 | m = 0,
|  | uint16 | l = 0 )

inline

Default constructor.

Parameters

  c | - the key code.
  m | - the key masks.
  l | - the keyboard layout

References code, layout, and mask.

Referenced by map_to_layout(), operator!=(), operator<(), and operator==().

## KeyEvent() [2/2]

scim::KeyEvent::KeyEvent | ( | const String & | str | ) |

inline

Constructor, construct a key event from a string.

Parameters

  str | the key string, eg. "Control+space"

References code, layout, mask, and scim::scim_string_to_key().

## Member Function Documentation

## empty()

bool scim::KeyEvent::empty | ( |  | ) | const

inline

Check if this KeyEvent is empty.

Returns
  true if this is a empty event.

References code, and mask.

## get_ascii_code()

char scim::KeyEvent::get_ascii_code | ( |  | ) | const

Get the ascii code of this key event.

Not all key events have ascii codes.

Returns
  the ascii code of this key event. Zero means no ascii code.

## get_unicode_code()

ucs4_t scim::KeyEvent::get_unicode_code | ( |  | ) | const

Get the Unicode code of this key event.

Not all key events have unicode codes.

Returns
  The Unicode code of this key event. Zero means no unicode code.

## get_key_string()

String scim::KeyEvent::get_key_string | ( |  | ) | const

Get the string of this key event.

Not all key events can be converted to string.

Returns
  The string of this key event.

## map_to_layout()

KeyEvent scim::KeyEvent::map_to_layout | ( | KeyboardLayout | new_layout | ) | const

Map this KeyEvent to another Keyboard Layout.

This function only covers the key range of default US PC keyboard. All additional keys in other layouts will never be mapped.

If the current layout is Unknown or the new_layout is invalid or it's an Unicode embedded KeyEvent, then it'll not be mapped and the identical KeyEvent will be returned.

If you want to check if the mapping is successful, just compare the layout of returned KeyEvent and new_layout to see if they are equal.

Parameters

  new_layout | The Keyboard Layout to be mapped to.

Returns
  The new KeyEvent according to the given layout.

References KeyEvent().

## is_shift_down()

bool scim::KeyEvent::is_shift_down | ( |  | ) | const

inline

Check if the Shift key is pressed down.

References mask, and scim::SCIM_KEY_ShiftMask.

## is_caps_lock_down()

bool scim::KeyEvent::is_caps_lock_down | ( |  | ) | const

inline

Check if the CapsLock key is pressed down.

References mask, and scim::SCIM_KEY_CapsLockMask.

## is_control_down()

bool scim::KeyEvent::is_control_down | ( |  | ) | const

inline

Check if the Ctrl key is pressed down.

References mask, and scim::SCIM_KEY_ControlMask.

## is_alt_down()

bool scim::KeyEvent::is_alt_down | ( |  | ) | const

inline

Check if the Alt key is pressed down.

References mask, and scim::SCIM_KEY_AltMask.

## is_meta_down()

bool scim::KeyEvent::is_meta_down | ( |  | ) | const

inline

Check if the Meta key is pressed down.

References mask, and scim::SCIM_KEY_MetaMask.

## is_super_down()

bool scim::KeyEvent::is_super_down | ( |  | ) | const

inline

Check if the Super key is pressed down.

References mask, and scim::SCIM_KEY_SuperMask.

## is_hyper_down()

bool scim::KeyEvent::is_hyper_down | ( |  | ) | const

inline

Check if the Hyper key is pressed down.

References mask, and scim::SCIM_KEY_HyperMask.

## is_num_lock_down()

bool scim::KeyEvent::is_num_lock_down | ( |  | ) | const

inline

Check if the num lock key is pressed down.

References mask, and scim::SCIM_KEY_NumLockMask.

## is_key_press()

bool scim::KeyEvent::is_key_press | ( |  | ) | const

inline

Check if it's a key press event.

References mask, and scim::SCIM_KEY_ReleaseMask.

## is_key_release()

bool scim::KeyEvent::is_key_release | ( |  | ) | const

inline

Check if it's a key release event.

References mask, and scim::SCIM_KEY_ReleaseMask.

## operator==()

bool scim::KeyEvent::operator== | ( | const KeyEvent & | key | ) | const

inline

Compare two key events.

Returns
  true if they are equal.

References code, KeyEvent(), and mask.

## operator!=()

bool scim::KeyEvent::operator!= | ( | const KeyEvent & | key | ) | const

inline

Compare two key events.

Returns
  true if they are not equal.

References code, KeyEvent(), and mask.

## operator<()

bool scim::KeyEvent::operator< | ( | const KeyEvent & | key | ) | const

inline

Compare two key events.

This operator is mainly for sorting.

Returns
  true if the first is smaller.

References code, KeyEvent(), and mask.

## is_lock_down()

bool scim::KeyEvent::is_lock_down | ( |  | ) | const

inline

Check if the lock key is pressed down.

For backward API compatibility, do not use it in new code.

References mask, and scim::SCIM_KEY_LockMask.

## is_mod1_down()

bool scim::KeyEvent::is_mod1_down | ( |  | ) | const

inline

Check if the mod1 key is pressed down.

For backward API compatibility, do not use it in new code.

References mask, and scim::SCIM_KEY_Mod1Mask.

## is_mod2_down()

bool scim::KeyEvent::is_mod2_down | ( |  | ) | const

inline

Check if the mod2 key is pressed down.

For backward API compatibility, do not use it in new code.

References mask, and scim::SCIM_KEY_Mod2Mask.

## is_mod3_down()

bool scim::KeyEvent::is_mod3_down | ( |  | ) | const

inline

Check if the mod3 key is pressed down.

For backward API compatibility, do not use it in new code.

References mask, and scim::SCIM_KEY_Mod3Mask.

## is_mod4_down()

bool scim::KeyEvent::is_mod4_down | ( |  | ) | const

inline

Check if the mod4 key is pressed down.

For backward API compatibility, do not use it in new code.

References mask, and scim::SCIM_KEY_Mod4Mask.

## is_mod5_down()

bool scim::KeyEvent::is_mod5_down | ( |  | ) | const

inline

Check if the mod5 key is pressed down.

For backward API compatibility, do not use it in new code.

References mask, and scim::SCIM_KEY_Mod5Mask.

## is_scroll_lock_down()

bool scim::KeyEvent::is_scroll_lock_down | ( |  | ) | const

inline

Check if the scroll lock key is pressed down.

For backward API compatibility, do not use it in new code.

References mask, and scim::SCIM_KEY_ScrollLockMask.

## Member Data Documentation

## code

uint32 scim::KeyEvent::code

key code

Referenced by empty(), KeyEvent(), KeyEvent(), operator!=(), operator<(), and operator==().

## mask

uint16 scim::KeyEvent::mask

modifier keys' mask

Referenced by empty(), is_alt_down(), is_caps_lock_down(), is_control_down(), is_hyper_down(), is_key_press(), is_key_release(), is_lock_down(), is_meta_down(), is_mod1_down(), is_mod2_down(), is_mod3_down(), is_mod4_down(), is_mod5_down(), is_num_lock_down(), is_scroll_lock_down(), is_shift_down(), is_super_down(), KeyEvent(), KeyEvent(), operator!=(), operator<(), and operator==().

## layout

uint16 scim::KeyEvent::layout

keyboard layout identifier

Referenced by KeyEvent(), and KeyEvent().

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

- scim_event.h