Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
KeyEvent.h
Go to the documentation of this file.
1 #pragma once
15 #include <Ultralight/Defines.h>
16 #include <Ultralight/KeyCodes.h>
17 #include <Ultralight/String.h>
18 #ifdef __OBJC__
19 #import <AppKit/NSEvent.h>
20 #endif
21 
22 namespace ultralight {
23 
30 class UExport KeyEvent {
31 public:
35  enum Type {
38 
41 
44 
47  };
48 
53  KeyEvent();
54 
55 #ifdef _WIN32
56  KeyEvent(Type type, uintptr_t wparam, intptr_t lparam, bool is_system_key);
60 #endif
61 
62 #ifdef __OBJC__
63  KeyEvent(NSEvent* evt);
67 #endif
68 
72  enum Modifiers : uint8_t {
74  kMod_AltKey = 1 << 0,
75 
77  kMod_CtrlKey = 1 << 1,
78 
80  kMod_MetaKey = 1 << 2,
81 
83  kMod_ShiftKey = 1 << 3,
84  };
85 
87  // The type of this KeyEvent
89  Type type;
90 
95  unsigned modifiers;
96 
98  // The virtual key-code associated with this keyboard event. This is either
99  // directly from the event (ie, WPARAM on Windows) or via a mapping function.
100  // You can see a full list of the possible virtual key-codes in
101  // KeyboardCodes.h
103  int virtual_key_code;
104 
111 
119 
125 
132 
136  bool is_keypad;
137 
143 
150 };
151 
161 void UExport GetKeyIdentifierFromVirtualKeyCode(int virtual_key_code,
162  String& key_identifier_result);
163 
164 } // namespace ultralight
Type
The various KeyEvent types.
Definition: KeyEvent.h:35
String key_identifier
This is a string identifying the key that was pressed.
Definition: KeyEvent.h:118
String unmodified_text
The text generated by this keyboard event before all modifiers except shift are applied.
Definition: KeyEvent.h:131
int native_key_code
The actual key-code generated by the platform.
Definition: KeyEvent.h:110
void UExport GetKeyIdentifierFromVirtualKeyCode(int virtual_key_code, String &key_identifier_result)
Utility function for generating a key identifier string from a virtual key-code.
Modifiers
An enumeration of the different keyboard modifiers.
Definition: KeyEvent.h:72
The header for the KeyCodes definitions.
This is a set of common JavaScriptCore Helper functions to simplify sample code.
Definition: App.h:19
UTF-16 String container with conversions for UTF-8 and UTF-32.
Definition: String.h:27
bool is_keypad
Whether or not this is a keypad event.
Definition: KeyEvent.h:136
bool is_auto_repeat
Whether or not this was generated as the result of an auto-repeat (eg, holding down a key).
Definition: KeyEvent.h:142
Character input type (this event generates text in input fields)
Definition: KeyEvent.h:46
unsigned modifiers
The current state of the keyboard.
Definition: KeyEvent.h:95
The header for the String class.
bool is_system_key
Whether or not the pressed key is a "system key".
Definition: KeyEvent.h:149
A generic keyboard event that can be created from a platform event or synthesized from scratch.
Definition: KeyEvent.h:30
String text
The actual text generated by this keyboard event.
Definition: KeyEvent.h:124