mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 19:16:02 +00:00
LibWeb: Add a helper to lookup a key code from its string name
This commit is contained in:
parent
a46edc2f8b
commit
f14e7c7261
Notes:
github-actions[bot]
2024-08-20 07:30:49 +00:00
Author: https://github.com/trflynn89
Commit: f14e7c7261
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1129
1 changed files with 12 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <AK/EnumBits.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Web::UIEvents {
|
||||
|
@ -159,6 +160,17 @@ enum KeyCode : u8 {
|
|||
};
|
||||
size_t const key_code_count = Key_Menu + 1;
|
||||
|
||||
constexpr KeyCode key_code_from_string(StringView key_name)
|
||||
{
|
||||
#define __ENUMERATE_KEY_CODE(name, ui_name) \
|
||||
if (key_name == ui_name##sv) \
|
||||
return KeyCode::Key_##name;
|
||||
ENUMERATE_KEY_CODES
|
||||
#undef __ENUMERATE_KEY_CODE
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
enum KeyModifier {
|
||||
Mod_None = 0x00,
|
||||
Mod_Alt = (1 << 0),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue