diff --git a/Tests/LibWeb/Text/expected/UIEvents/KeyEvent-numpad-keys.txt b/Tests/LibWeb/Text/expected/UIEvents/KeyEvent-numpad-keys.txt
new file mode 100644
index 00000000000..a3eedbad69a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/UIEvents/KeyEvent-numpad-keys.txt
@@ -0,0 +1,20 @@
+key="0" code=Numpad0
+key="1" code=Numpad1
+key="2" code=Numpad2
+key="3" code=Numpad3
+key="4" code=Numpad4
+key="5" code=Numpad5
+key="6" code=Numpad6
+key="7" code=Numpad7
+key="8" code=Numpad8
+key="9" code=Numpad9
+key="+" code=NumpadAdd
+key="," code=NumpadComma
+key="." code=NumpadDecimal
+key="/" code=NumpadDivide
+key="*" code=NumpadMultiply
+key="-" code=NumpadSubtract
+key="=" code=NumpadEqual
+key="#" code=NumpadHash
+key="(" code=NumpadParenLeft
+key=")" code=NumpadParenRight
diff --git a/Tests/LibWeb/Text/input/UIEvents/KeyEvent-numpad-keys.html b/Tests/LibWeb/Text/input/UIEvents/KeyEvent-numpad-keys.html
new file mode 100644
index 00000000000..97041bc11c1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/UIEvents/KeyEvent-numpad-keys.html
@@ -0,0 +1,38 @@
+
+
+
diff --git a/Userland/Libraries/LibWeb/Internals/Internals.cpp b/Userland/Libraries/LibWeb/Internals/Internals.cpp
index 9fa96ae760e..a97cd04b7f2 100644
--- a/Userland/Libraries/LibWeb/Internals/Internals.cpp
+++ b/Userland/Libraries/LibWeb/Internals/Internals.cpp
@@ -74,21 +74,21 @@ JS::Object* Internals::hit_test(double x, double y)
return nullptr;
}
-void Internals::send_text(HTML::HTMLElement& target, String const& text)
+void Internals::send_text(HTML::HTMLElement& target, String const& text, WebIDL::UnsignedShort modifiers)
{
auto& page = internals_page();
target.focus();
for (auto code_point : text.code_points())
- page.handle_keydown(UIEvents::code_point_to_key_code(code_point), 0, code_point);
+ page.handle_keydown(UIEvents::code_point_to_key_code(code_point), modifiers, code_point);
}
-void Internals::send_key(HTML::HTMLElement& target, String const& key_name)
+void Internals::send_key(HTML::HTMLElement& target, String const& key_name, WebIDL::UnsignedShort modifiers)
{
auto key_code = UIEvents::key_code_from_string(key_name);
target.focus();
- internals_page().handle_keydown(key_code, 0, 0);
+ internals_page().handle_keydown(key_code, modifiers, 0);
}
void Internals::commit_text()
diff --git a/Userland/Libraries/LibWeb/Internals/Internals.h b/Userland/Libraries/LibWeb/Internals/Internals.h
index 7674273eac3..2623a5b3759 100644
--- a/Userland/Libraries/LibWeb/Internals/Internals.h
+++ b/Userland/Libraries/LibWeb/Internals/Internals.h
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
namespace Web::Internals {
@@ -24,8 +25,8 @@ public:
void gc();
JS::Object* hit_test(double x, double y);
- void send_text(HTML::HTMLElement&, String const&);
- void send_key(HTML::HTMLElement&, String const&);
+ void send_text(HTML::HTMLElement&, String const&, WebIDL::UnsignedShort modifiers);
+ void send_key(HTML::HTMLElement&, String const&, WebIDL::UnsignedShort modifiers);
void commit_text();
void click(double x, double y);
diff --git a/Userland/Libraries/LibWeb/Internals/Internals.idl b/Userland/Libraries/LibWeb/Internals/Internals.idl
index 66c4d51d502..665b55de9a8 100644
--- a/Userland/Libraries/LibWeb/Internals/Internals.idl
+++ b/Userland/Libraries/LibWeb/Internals/Internals.idl
@@ -9,8 +9,15 @@ interface Internals {
undefined gc();
object hitTest(double x, double y);
- undefined sendText(HTMLElement target, DOMString text);
- undefined sendKey(HTMLElement target, DOMString keyName);
+ const unsigned short MOD_NONE = 0;
+ const unsigned short MOD_ALT = 1;
+ const unsigned short MOD_CTRL = 2;
+ const unsigned short MOD_SHIFT = 4;
+ const unsigned short MOD_SUPER = 8;
+ const unsigned short MOD_KEYPAD = 16;
+
+ undefined sendText(HTMLElement target, DOMString text, optional unsigned short modifiers = 0);
+ undefined sendKey(HTMLElement target, DOMString keyName, optional unsigned short modifiers = 0);
undefined commitText();
undefined click(double x, double y);
diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp
index 98e49be8499..0eb34e53920 100644
--- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp
+++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp
@@ -326,6 +326,8 @@ static ErrorOr get_event_code(KeyCode platform_key, unsigned modifiers)
return "Numpad9"_string;
case KeyCode::Key_Plus:
return "NumpadAdd"_string;
+ case KeyCode::Key_Comma:
+ return "NumpadComma"_string;
case KeyCode::Key_Period:
case KeyCode::Key_Delete:
return "NumpadDecimal"_string;
@@ -334,9 +336,17 @@ static ErrorOr get_event_code(KeyCode platform_key, unsigned modifiers)
case KeyCode::Key_Return:
return "NumpadEnter"_string;
case KeyCode::Key_Asterisk:
- return "NumpadAsterisk"_string;
+ return "NumpadMultiply"_string;
case KeyCode::Key_Minus:
return "NumpadSubtract"_string;
+ case KeyCode::Key_Equal:
+ return "NumpadEqual"_string;
+ case KeyCode::Key_Hashtag:
+ return "NumpadHash"_string;
+ case KeyCode::Key_LeftParen:
+ return "NumpadParenLeft"_string;
+ case KeyCode::Key_RightParen:
+ return "NumpadParenRight"_string;
default:
break;
}