Coverage Report

Created: 2025-09-05 06:52

/src/serenity/Userland/Libraries/LibWeb/UIEvents/KeyCode.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2024, the SerenityOS developers.
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/StringView.h>
10
11
// FIXME: Stop including Kernel here eventually.
12
#include <Kernel/API/KeyCode.h>
13
14
namespace Web::UIEvents {
15
16
using KeyCode = ::KeyCode;
17
using enum KeyCode;
18
19
using KeyModifier = ::KeyModifier;
20
using enum KeyModifier;
21
22
constexpr KeyCode key_code_from_string(StringView key_name)
23
0
{
24
0
#define __ENUMERATE_KEY_CODE(name, ui_name) \
25
0
    if (key_name == ui_name##sv)            \
26
0
        return KeyCode::Key_##name;
27
0
    ENUMERATE_KEY_CODES
28
0
#undef __ENUMERATE_KEY_CODE
29
30
0
    VERIFY_NOT_REACHED();
31
0
}
32
33
inline KeyCode code_point_to_key_code(u32 code_point)
34
0
{
35
0
    return ::code_point_to_key_code(code_point);
36
0
}
37
38
}