struct CCL::KeyEvent

Overview

Keyboard Event. More…

#include <guievent.h>

struct KeyEvent: public CCL::GUIEvent
{
    // enums

    enum EventType;

    // fields

    VirtualKey vKey;
    uchar character;
    uchar composedCharacter;
    KeyState state;

    // construction

    KeyEvent (
        int eventType = kKeyDown,
        VirtualKey vKey = VKey::kUnknown,
        uchar character = 0,
        uchar composedCharacter = 0,
        const KeyState& state = KeyState (),
        double eventTime = 0
    );

    // methods

    bool isValid () const;
    bool isVKeyValid () const;
    bool isCharValid () const;
    bool isComposedCharValid () const;
    bool isRepeat () const;
    bool isSimilar (const KeyEvent& e) const;
    bool operator == (const KeyEvent& k) const;
    bool operator != (const KeyEvent& k) const;
    bool fromString (StringRef string);
    void toString (String& string, bool translated = false) const;
};

Inherited Members

public:
    // enums

    enum EventClass;

    // fields

    int eventClass;
    int eventType;
    double eventTime;

    // methods

    template  <class Event>
    const Event* as () const;

    const PointerEvent* as () const;

Detailed Documentation

Keyboard Event.

Notes about composed characters and dead keys:

‘character’ is the character produced by a single key press, possibly modified by the ‘shift’ modifier. Dead keys are not taken into account.

‘composedCharacter’ is the character produced by a sequence of key presses, including dead keys and modifiers. On most platforms, ‘composedCharacter’ will only be valid for kKeyDown events.

Examples (Windows, German locale):

Keys

character

composedCharacter

Alt Gr + E

e

(euro sign)

Shift + E

E

E

Alt Gr + Shift + (eszett)

? (question mark)

(uppercase eszett)

(caret) followed by A

a

(a with circumflex)

Repeat behavior:

| macOS                     | Windows              | Linux               |
|---------------------------|----------------------|---------------------|
| Alphanumeric characters   | All characters are   | All characters are  |
| and diacritics are not    | repeated. Characters | repeated.           |
| repeated.                 | with diacritics are  |                     |
|                           | repeated without     |                     |
|                           | diacritics.          |                     |

<>