AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
KeyboardEvent.hpp
1/*
2Copyright (C) 2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_DOM_KEYBOARDEVENT_H
17#define AEONGUI_DOM_KEYBOARDEVENT_H
18#include "aeongui/dom/UIEvent.hpp"
19#include "aeongui/dom/EventModifierInit.hpp"
20
21namespace AeonGUI
22{
23 namespace DOM
24 {
29 {
30 DOMString key{""};
31 DOMString code{""};
32 unsigned long location{0};
33 bool repeat{false};
34 bool isComposing{false};
35 };
36
43 class KeyboardEvent : public UIEvent
44 {
45 public:
46 static constexpr unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;
47 static constexpr unsigned long DOM_KEY_LOCATION_LEFT = 0x01;
48 static constexpr unsigned long DOM_KEY_LOCATION_RIGHT = 0x02;
49 static constexpr unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;
50
55 DLL KeyboardEvent ( const DOMString& type, const KeyboardEventInit& eventInitDict = {} );
56
59 DLL const DOMString& key() const;
62 DLL const DOMString& code() const;
65 DLL unsigned long location() const;
68 DLL bool ctrlKey() const;
71 DLL bool shiftKey() const;
74 DLL bool altKey() const;
77 DLL bool metaKey() const;
80 DLL bool repeat() const;
83 DLL bool isComposing() const;
87 DLL bool getModifierState ( const DOMString& keyArg ) const;
88
89 private:
90 DOMString m_key;
91 DOMString m_code;
92 unsigned long m_location{0};
93 bool m_ctrlKey{false};
94 bool m_shiftKey{false};
95 bool m_altKey{false};
96 bool m_metaKey{false};
97 bool m_repeat{false};
98 bool m_isComposing{false};
99 bool m_modifierAltGraph{false};
100 bool m_modifierCapsLock{false};
101 bool m_modifierFn{false};
102 bool m_modifierFnLock{false};
103 bool m_modifierHyper{false};
104 bool m_modifierNumLock{false};
105 bool m_modifierScrollLock{false};
106 bool m_modifierSuper{false};
107 bool m_modifierSymbol{false};
108 bool m_modifierSymbolLock{false};
109 };
110 }
111}
112#endif
constexpr const DOMString & type() const
Get the event type.
Definition Event.hpp:73
bool isComposing() const
Check if part of a composition session.
Definition KeyboardEvent.cpp:78
bool getModifierState(const DOMString &keyArg) const
Query the state of a modifier key.
Definition KeyboardEvent.cpp:83
bool ctrlKey() const
Check if Control modifier was active.
Definition KeyboardEvent.cpp:58
static constexpr unsigned long DOM_KEY_LOCATION_RIGHT
Right key location.
Definition KeyboardEvent.hpp:48
static constexpr unsigned long DOM_KEY_LOCATION_LEFT
Left key location.
Definition KeyboardEvent.hpp:47
KeyboardEvent(const DOMString &type, const KeyboardEventInit &eventInitDict={})
Construct a KeyboardEvent.
Definition KeyboardEvent.cpp:22
bool metaKey() const
Check if Meta modifier was active.
Definition KeyboardEvent.cpp:70
unsigned long location() const
Get the key location.
Definition KeyboardEvent.cpp:54
bool repeat() const
Check if the key is repeating.
Definition KeyboardEvent.cpp:74
bool shiftKey() const
Check if Shift modifier was active.
Definition KeyboardEvent.cpp:62
static constexpr unsigned long DOM_KEY_LOCATION_NUMPAD
Numpad key location.
Definition KeyboardEvent.hpp:49
static constexpr unsigned long DOM_KEY_LOCATION_STANDARD
Standard key location.
Definition KeyboardEvent.hpp:46
const DOMString & code() const
Get the physical key code.
Definition KeyboardEvent.cpp:50
const DOMString & key() const
Get the key value.
Definition KeyboardEvent.cpp:46
bool altKey() const
Check if Alt modifier was active.
Definition KeyboardEvent.cpp:66
UIEvent(const DOMString &type, const UIEventInit &eventInitDict={})
Construct a UIEvent.
Definition UIEvent.cpp:21
Shared modifier key initialization dictionary.
Definition EventModifierInit.hpp:31
Initialization dictionary for KeyboardEvent construction.
Definition KeyboardEvent.hpp:29
bool repeat
Whether the key is held down (repeating).
Definition KeyboardEvent.hpp:33
DOMString code
The physical key code.
Definition KeyboardEvent.hpp:31
bool isComposing
Whether part of a composition session.
Definition KeyboardEvent.hpp:34
DOMString key
The key value of the key pressed.
Definition KeyboardEvent.hpp:30
unsigned long location
Key location on the device.
Definition KeyboardEvent.hpp:32