Bug 16972 - in textarea ctrl+enter produces keypress event with keyCode=10, not 13
Summary: in textarea ctrl+enter produces keypress event with keyCode=10, not 13
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar, PlatformOnly
Depends on:
Blocks:
 
Reported: 2008-01-22 02:46 PST by Artemy Tregubenko
Modified: 2009-10-27 19:38 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Artemy Tregubenko 2008-01-22 02:46:47 PST
I assign keypress listener to textarea. When I press Ctrl+Enter, this listener receives event parameter with keyCode value equal to 10. But when I press just Enter, keyCode is equal to 13. It is also 13 for Ctrl+Enter in other major browsers. 

This is true for Safari 3.0.4 and WebKit r29711
Comment 1 Alexey Proskuryakov 2008-01-22 06:21:03 PST
In my testing, Internet Explorer 7 behaves the same as Safari.

It's a bug that we produce different codes for Ctrl+Enter on Windows and on Mac, but I would qualify it as a Mac-side bug.
Comment 2 Alexey Proskuryakov 2008-01-22 06:21:48 PST
In other words, I think that key code should equal 10 for Ctrl+Enter, matching IE.
Comment 3 Artemy Tregubenko 2008-01-22 06:48:28 PST
Sorry, I wan't attentive enough while testing IE7. I tested _keydown_ event in it, and it does produce 10 on ctrl+enter for _keypress_ event.
Comment 4 Alexey Proskuryakov 2008-01-22 07:13:59 PST
I'd like to keep this open to track a bug on the Mac side - we don't have this quirk there yet, but we should.
Comment 5 Artemy Tregubenko 2008-01-22 07:26:08 PST
Then please document it! : )
Comment 6 Alexey Proskuryakov 2008-03-27 13:43:59 PDT
<rdar://problem/5826166>
Comment 7 Erik Arvidsson 2009-10-27 17:24:01 PDT
keypress should use the charCode (which is 13) .

This seems correct on Safari Mac but wrong on Safari Windows which returns keyCode 10.

What does the rdar bug say we want to do here?
Comment 8 Alexey Proskuryakov 2009-10-27 18:02:18 PDT
(In reply to comment #7)
> keypress should use the charCode (which is 13) .

You disagree with above comments - could you please explain why you find them wrong?
Comment 9 Erik Arvidsson 2009-10-27 18:30:52 PDT
(In reply to comment #8)
> (In reply to comment #7)
> > keypress should use the charCode (which is 13) .
> 
> You disagree with above comments - could you please explain why you find them
> wrong?

I think the whole keypress issue is giving me too many sleepless nights.

The reason why I found it wrong was two reasons.

1. It is valuable to be able to do String.fromCharCode(event.keyCode) in a keypress handler.
2. This is what Firefox does.

I think I'm starting to lean towards not touching keypress again and tell people to only use keydown, keyup and textInput.
Comment 10 Alexey Proskuryakov 2009-10-27 18:59:50 PDT
> 2. This is what Firefox does.

As a general rule, we do what IE does for key handling.
Comment 11 Erik Arvidsson 2009-10-27 19:38:15 PDT
(In reply to comment #10)
> > 2. This is what Firefox does.
> 
> As a general rule, we do what IE does for key handling.

We should update the title to say:

Wrong keyCode for Ctrl+Enter on Mac (should be 10 and not 13)