Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6e8432fe7c28c46ed29b0862ff2987bf1777dd45
      
https://github.com/WebKit/WebKit/commit/6e8432fe7c28c46ed29b0862ff2987bf1777dd45
  Author: Karl Dubost <[email protected]>
  Date:   2026-03-15 (Sun, 15 Mar 2026)

  Changed paths:
    M 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-control-expected.txt
    M 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-control-expected.txt
    M 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-expected.txt
    M 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-option-expected.txt
    M 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-shift-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/keypress-not-fired-for-modifier-shortcuts-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/keypress-not-fired-for-modifier-shortcuts.html
    M LayoutTests/platform/ios/TestExpectations
    M Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
    M Source/WebCore/page/EventHandler.cpp

  Log Message:
  -----------
  Suppress keypress events for Meta+key and Ctrl+key shortcuts
https://bugs.webkit.org/show_bug.cgi?id=30397
rdar://4360235

Reviewed by Ryosuke Niwa, Aditya Keerthi, and Abrar Rahman Protyasha.

Per the UI Events spec (https://w3c.github.io/uievents/#keypress), keypress
should only fire for keys that produce a character value. Safari was firing
keypress for modifier shortcuts like Cmd+C and Cmd+V, unlike Chrome and Firefox.

This caused a webcompat bug on tools.usps.com where pasting a ZIP code with
Cmd+V was blocked because the site's keypress handler saw charCode 118 ('v'),
treated it as a non-digit character, and called preventDefault().

Extend shouldAvoidDispatchingKeyPressEvent in EventHandler::internalKeyEvent to
suppress keypress dispatch when metaKey or controlKey is active. altKey is not
suppressed because Option+key produces characters (e.g. accents).

This is also gated for the future releases to avoid any breakages for
Cocoa applications with this change of behavior, which has existed for a long
time.

Test: 
imported/w3c/web-platform-tests/uievents/keyboard/keypress-not-fired-for-modifier-shortcuts.html

* 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-control-expected.txt:
* 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-control-expected.txt:
* 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-expected.txt:
* 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-option-expected.txt:
* 
LayoutTests/fast/events/ios/key-events-comprehensive/key-events-meta-shift-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/keypress-not-fired-for-modifier-shortcuts-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/keypress-not-fired-for-modifier-shortcuts.html:
 Added.
* LayoutTests/platform/ios/TestExpectations:
  We are excluding the test from iOS for now because there are issues in
  the way send_keys() is (not) working on iOS. This should be fixed in a
  followup tests.

* Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::internalKeyEvent):

Canonical link: https://commits.webkit.org/309300@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to