<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>14104</bug_id>
          
          <creation_ts>2007-06-12 15:39:04 -0700</creation_ts>
          <short_desc>Win32: Ctrl+key fires keyup, but not keydown or keypress</short_desc>
          <delta_ts>2007-12-21 12:27:24 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc>http://unixpapa.com/js/testkey.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar, PlatformOnly</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="John Fraser">john</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>heatherita</cc>
    
    <cc>oliver</cc>
    
    <cc>sysadmin</cc>
    
    <cc>vicki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7751</commentid>
    <comment_count>0</comment_count>
    <who name="John Fraser">john</who>
    <bug_when>2007-06-12 15:39:04 -0700</bug_when>
    <thetext>On Windows, pressing Ctrl+[some keys] only fires the keyup event.  Pressing Ctrl +[some other keys] does not fire any JavaScript key events at all.

Here&apos;s how it breaks down:

Ctrl+&lt;key&gt; only fires keyup:
  A,C,E,G,J,R,V,X,Z,0,-,=,insert

Ctrl+&lt;key&gt; fires no events:
  D,F,K,L,M,N,O,P,Q,T,W

Note that if a key is on either list, you can&apos;t use preventDefault (or an onkeypress/onkeydown handler that returns false) to override its default behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>218</commentid>
    <comment_count>1</comment_count>
    <who name="Akmin">sysadmin</who>
    <bug_when>2007-09-21 02:43:39 -0700</bug_when>
    <thetext>same issue happened. i also confirm it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>201</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-09-21 06:25:10 -0700</bug_when>
    <thetext>&lt;rdar://problem/5497037&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26</commentid>
    <comment_count>3</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2007-09-24 21:25:38 -0700</bug_when>
    <thetext>Righto, the problem is fairly simple, although the solution is non-trivial.

CWnd::PreTranslateMessage is being called prior to the key events being passed into the WebView, this results in ::TranslateAccelerator being called and converting the key events into commands, causing the key events to *never* reach the webview, so there is never a JS event.

The events that never fire keyup are those events that change state in a way that means the key up makes no sense:
D: brings up bookmarks, so changes focus target
F: find, changing focus target
K: changes focus target
L: goes to the location bar, changing focus target
M: minimises, thus changing focus target
N: new window, so changing focus target
O:open dialog, changed focus
P:print dialog, so changes focus
Q:quits -- clearly there can&apos;t be an keyup
T:new tabs, changes focus
W:closes tab, clearly can&apos;t send a keyup

The fix really needs to be to put off handling of the accelerators until after the keydown or keypress has occurred.  As yet I haven&apos;t studied the other major browsers in sufficient detail to determine when they actually handle the accelerators, but i suspect it is after the keydown event has been fired and before the keypress event.

This will require a platform specific handler in WebCore::EventHandler, probably bool WebCore::EventHandler::handleCommandKeys(const PlatformKeyEvent&amp;), or similar.  This reordering should also allow us to prevent key combos like cmd-w/q from being blocked by the DOM, which is just silly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20</commentid>
    <comment_count>4</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2007-09-24 22:20:39 -0700</bug_when>
    <thetext>


Here&apos;s the output of the attached test case when using the accelerator combo for copy (cmd-c on mac, ctrl-c on windows)
Safari 3 beta (3.0.4), Mac:
    * keyDown: U+0043, 67
    * keyPress: U+0043, 99

Firefox 2, Mac:
    * keyDown: undefined, 224
    * keyDown: undefined, 67
    * keyPress: undefined, 0
    * keyUp: undefined, 67
    * keyUp: undefined, 224

Firefox 3 alpha (3.0a6), Mac:
    * keyDown: undefined, 224
    * keyUp: undefined, 224

Opera 9.5 alpha (4404), Mac:
    * keyDown: undefined, 17
    * keyPress: undefined, 17
    * keyDown: undefined, 67
    * keyPress: undefined, 99
    * keyUp: undefined, 67
    * keyUp: undefined, 17

Internet Explorer 7, Win (obviously :D):
    * keyDown: undefined, 17
    * keyDown: undefined, 67
    * keyUp: undefined, 67
    * keyUp: undefined, 17

Firefox 2, Win:
    * keyDown: undefined, 17
    * keyDown: undefined, 67
    * keyPress: undefined, 0
    * keyUp: undefined, 67
    * keyUp: undefined, 17

Firefox 3 (3.0a6), Win -- identical to firefox 2, win.

Opera 9.5 alpha (9500):
    * keyDown: undefined, 17
    * keyPress: undefined, 17
    * keyDown: undefined, 67
    * keyPress: undefined, 67
    * keyUp: undefined, 67
    * keyUp: undefined, 17



</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21</commentid>
    <comment_count>5</comment_count>
      <attachid>16380</attachid>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2007-09-24 22:22:17 -0700</bug_when>
    <thetext>Created attachment 16380
Simple test case

And of course WebKit/Win currently doesn&apos;t send any accelerators :-/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63172</commentid>
    <comment_count>6</comment_count>
    <who name="John Fraser">john</who>
    <bug_when>2007-12-03 13:01:13 -0800</bug_when>
    <thetext>BTW, in a perfect world I&apos;d still be able to block everything except Ctrl-W and Ctrl-Q.  Since you&apos;re looking at the behavior of other browsers, the keys I use at http://wmd-editor.com/demo work on every major browser except Konqueror and Safari/Win -- and they do include Cmd/Ctrl-K and L from the list of keys that change browser state.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64978</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-12-21 12:27:24 -0800</bug_when>
    <thetext>Turns out that this problem is mostly within Safari, not WebKit. As such, I&apos;m closing this bug as INVALID, and it will continue to be tracked in Radar.

Thank you for reporting this, and for providing insightful comments!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>16380</attachid>
            <date>2007-09-24 22:22:17 -0700</date>
            <delta_ts>2007-09-24 22:22:17 -0700</delta_ts>
            <desc>Simple test case</desc>
            <filename>keyTest.html</filename>
            <type>text/html</type>
            <size>477</size>
            <attacher name="Oliver Hunt">oliver</attacher>
            
              <data encoding="base64">PGlucHV0IHR5cGU9InRleHQiIG9ua2V5ZG93bj0ibG9nKCdrZXlEb3duOiAnICsgZXZlbnQua2V5
SWRlbnRpZmllciArJywgJyArIGV2ZW50LmtleUNvZGUpOyIgb25rZXlwcmVzcz0ibG9nKCdrZXlQ
cmVzczogJyArIGV2ZW50LmtleUlkZW50aWZpZXIgKycsICcgKyBldmVudC5rZXlDb2RlKSIgb25r
ZXl1cD0ibG9nKCdrZXlVcDogJyArIGV2ZW50LmtleUlkZW50aWZpZXIgKycsICcgK2V2ZW50Lmtl
eUNvZGUpIj4KPHVsIGlkPSJjb25zb2xlIj4KPC91bD4KPHNjcmlwdD4KZnVuY3Rpb24gbG9nKHN0
cikgewogICAgdmFyIGNvbnNvbGUgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiY29uc29sZSIp
OwogICAgdmFyIGxpID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgibGkiKTsKICAgIGxpLmFwcGVu
ZENoaWxkKGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHN0cikpOwogICAgY29uc29sZS5hcHBlbmRD
aGlsZChsaSk7Cn0KPC9zY3JpcHQ+
</data>

          </attachment>
      

    </bug>

</bugzilla>