onKeyPress event not fired when typing accents

Bug #58693 reported by Vojtěch Smejkal
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mozilla Firefox
Expired
Medium
firefox (Ubuntu)
Triaged
Medium
Unassigned
firefox-3.5 (Ubuntu)
Invalid
Medium
Unassigned

Bug Description

Browser javascript does not detect certain pressed keys.

Reproduce:
Set any HTML object onkeypress attribute like for example this:
<textarea onkeypress="alert(event.which);"></textarea>

If you press any key in this textarea, it shows you key code.
But if you want write ü or ä (German) in a way, that you press umlaut first and then letter,nothing happen.
It does not work with some other letters (áíéščřžě) and probably more.

It was tested in Opera, Firefox, Epiphany.
(in Opera you have to replace event.which by event.keyCode)

You can try it here: http://extender.ic.cz/keypress.html

Revision history for this message
Vojtěch Smejkal (smejky) wrote : keyPress does not work perfectly in browser javascript

Browser javascript does not detect certain pressed keys.

Reproduce:
Set any HTML object onkeypress attribute like for example this:
<textarea onkeypress="alert(event.which);"></textarea>

If you press any key in this textarea, it shows you key code.
But if you want write ü or ä (German) in a way, that you press umlaut first and then letter,
nothing happen. It does not work with some other letters (áíéščřžě) and probably more.

It was tested in Opera, Firefox, Epiphany.
(in Opera you have to replace event.which by event.keyCode)

You can try it here: http://extender.ic.cz/keypress.html

description: updated
Revision history for this message
Brian Murray (brian-murray) wrote :

Thanks for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering is this still an issue for you? Thanks in advance.

Revision history for this message
Vojtěch Smejkal (smejky) wrote :

There is a problem with specific lattin characters.

You want to write e.g. "latin small letter u with diaeresis" (ü). If you write it directly, it works - you get the keyCode. But if you press "diaeresis" first and then "u", nothing will happen.

Note: When run Firefox in Wine, it works.

Revision history for this message
Alexander Sack (asac) wrote :

we will try to get a tester in mozillateam to verify if your testcase is reproducible.

Changed in firefox:
assignee: nobody → mozilla-bugs
importance: Undecided → Medium
status: Unconfirmed → Needs Info
Revision history for this message
In , Carlos-barros (carlos-barros) wrote :

This bug is still valid. I've just checked it against firefox 2.0.0.8.
The old testcase is not valid anymore, as I've deleted it, but you can check it at:

http://mozile.mozdev.org/

Just click on the sample editor are and try to enter any accent using deadkeys. Then, try on windows and it will work.

Regards

Carlos Barros

Revision history for this message
In , Jacobsallan (jacobsallan) wrote :

Created an attachment (id=323821)
Test case demonstrating bug for keydown and keypress

The URL referenced in the bug report no longer exists. The mozile site referenced later is complex. This attachment is a simple test case. It also demonstrates that the bug is for keydown and keypress events (keyup is not in the example, but it almost certainly tracks keydown).

Revision history for this message
In , Jacobsallan (jacobsallan) wrote :

Using the attachment keydownEvent.html...

Dead key handling on Windows XP SP2/Firefox 2.0.0.14
====================================================

Use the control panel to set the keyboard mapping to US-International English.

Navigate to the URL referencing keydownEvent.html.
Click on Separate. If the button already reads Combine, do nothing.

Enter the character sequence `b
    ` will trigger
      keydown keycode=192
    b will trigger
      keydown keycode=66
      keypress charcode=0x60 (`)
      keypress charcode=0x62 (b)
Enter the character sequence ``
    ` will trigger
      keydown keycode=192
    ` will trigger
      keydown keycode=192
      keypress charcode=0x60 (`)
      keypress charcode=0x60 (`)
Enter the character sequence `<space>
    ` will trigger
      keydown keycode=192
    <space> will trigger
      keydown 32
      keypress 0x60 (`)
Enter the character sequence `a
    ` will trigger
      keydown keycode=192
    a will trigger
      keydown keycode=65
      keypress charcode=0xe0 (à)
Enter the character a
    a will trigger
      keypress charcode=0x61

Dead key handling on Ubuntu Linux 8.0.4
=======================================
Firefox 3.0b5
Use the System->Preferences->Keyboard menu option. In the Layouts tab
in the Keyboard Preferences dialog, add USA International (with dead
keys) and set it to the default.

Navigate to the URL referencing keydownEvent.html.
Click on the button Separate.

Enter the character sequence `b. This is not an allowed character
sequence.

Reload the page. Click on the button Separate.
Enter the character sequence ``
    ` will trigger nothing
    ` will trigger nothing
    The textfield will contain a single grave accent (`).
    The value of the textfield is correct.
    This is a bug in Firefox. Changes occur in the textfield value
    that are not signaled by keydown or keypress events.

Reload the page. Click on the button Separate.
Enter the character sequence `<space>
    ` will trigger nothing
    ` will trigger nothing
    The textfield will contain a single grave accent (`).
    The value of the textfield is correct.
    This is a bug in Firefox. Changes occur in the textfield value
    that are not signaled by keydown or keypress events.

Reload the page. Click on the button Separate.
Enter the character sequence `a
    ` will trigger nothing
    a will trigger nothing
    The textfield will contain a letter a with a grave accent (à).
    The value of the textfield is correct.
    This is a bug in Firefox. Changes occur in the textfield value
    that are not signaled by keydown or keypress events.

There are two bugs, some recent, that look to be duplicates of this one. 101279 (P4) and 192935 (Mac).

Revision history for this message
In , Publico (publico) wrote :

There are two other test pages on which you can test keyboard events, http://unixpapa.com/js/testkey.html and http://brain4.de/programmierecke/js/tastatur.php.

When you press a key sequence for á => "'" + "a" , only a keyup event
is fired without information about what key was pressed.

Firefox Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.8.1.14) Gecko/20080416 Fedora/2.0.0.14-1.fc7 Firefox/2.0.0.14

 I doesn't work with Linux. On Windows it is working right.

Revision history for this message
John Vivirito (gnomefreak) wrote : Re: keyPress does not work perfectly in browser javascript

Closing due to age. If this is still a problem in 3.0.7 please reopen this bug.
Also please reopen with all new information on how to reproduce this bug by giving us step by step instructions.
We also need what happens what is expected to happen.
To reopen the bug report you can click on the current status, under the Status column, and change the Status back to "New". Thanks again!

Changed in firefox (Ubuntu):
assignee: mozilla-bugs → nobody
Changed in firefox-3.0 (Ubuntu):
status: Incomplete → Invalid
Revision history for this message
Michael Barkholt (michael-barkholt) wrote :

This problem still exists in firefox-3.5/jaunty. The original test case still illustrates the problem perfectly. I'm using a danish keyboard where i need to press umlaut before o to get a ö.

Changed in firefox-3.0 (Ubuntu):
status: Invalid → New
Revision history for this message
Vojtěch Smejkal (smejky) wrote :

It's not only Firefox problem. This issue is manifesting in all browsers running on Linux - Epiphany, Opera, etc. Probably it is related to X-server.

Revision history for this message
Michael Barkholt (michael-barkholt) wrote :

There is at least one exception though. It seems to work correctly in the Linux Chromium builds for me (from PPA).

Revision history for this message
In , Mozilla-bugs-micahscomputing (mozilla-bugs-micahscomputing) wrote :

Ubuntu Bug:
https://bugs.launchpad.net/bugs/58693

One user confirms issue still exists in Firefox 3.5

Revision history for this message
Micah Gersten (micahg) wrote : Re: keyPress does not work perfectly in browser javascript

Thank you for your bug report. This bug has been reported to the developers of the software. You can track it and make comments at:
https://bugzilla.mozilla.org/show_bug.cgi?id=308820

Changed in firefox-3.5 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in firefox-3.0 (Ubuntu):
status: New → Triaged
summary: - keyPress does not work perfectly in browser javascript
+ onKeyPress event not fired when typing accents
Changed in firefox:
status: Unknown → New
Revision history for this message
In , Tyler Downer (tyler-downer) wrote :

This bug was reported on Firefox 2.x or older, which is no longer supported and will not be receiving any more updates. I strongly suggest that you update to Firefox 3.6.3 or later, update your plugins (flash, adobe, etc.), and retest in a new profile. If you still see the issue with the updated Firefox, please post here. Otherwise, please close as RESOLVED > WORKSFORME
http://www.mozilla.com
http://support.mozilla.com/kb/Managing+profiles
http://support.mozilla.com/kb/Safe+mode

Revision history for this message
In , Tyler Downer (tyler-downer) wrote :

No reply, INCOMPLETE. Please retest with Firefox 3.6.3 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.

Changed in firefox:
status: New → Invalid
Revision history for this message
Micah Gersten (micahg) wrote :

Can someone please test and see if this is still an issue in Firefox 3.6?

Changed in firefox-3.5 (Ubuntu):
status: Triaged → Incomplete
Changed in firefox:
importance: Unknown → Medium
status: Invalid → Expired
Revision history for this message
Jacobsallan (jacobsallan) wrote :

Still an issue in Firefox version 3.6.10 / Mozilla Firefox for Ubuntu canonical 1.0.

Revision history for this message
In , Jacobsallan (jacobsallan) wrote :

Yes. This still is a problem in Firefox 3.6.10 using a brand new profile.

Revision history for this message
Jacobsallan (jacobsallan) wrote :

Updated https://bugzilla.mozilla.org/show_bug.cgi?id=308820 . It's been moved to "RESOLVED INCOMPLETE" state. It needs to be reopened on the Mozilla side.

I think I know what is going on. Newer versions of Firefox are firing compositionstart, compositionupdate, and compositionend events; and not dispatching keypress events for dead key combinations. Refer to http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboardevents and http://www.w3.org/TR/DOM-Level-3-Events/#events-textevents .

There an error in the implementation of compositionend.

Firefox browsers are not firing textinput events. I believe that this is the only way Firefox will enable JavaScript developers to write code that is OS-independent. This is going to require a more senior Mozilla engineer to give the go-ahead as it will involve the talents of multiple engineers.

It's probably worth tracking bug https://bugzilla.mozilla.org/show_bug.cgi?id=447757 , as it has a new HTML example attached.

Revision history for this message
In , Jacobsallan (jacobsallan) wrote :

I think I know what is going on. Newer versions of Firefox are firing compositionstart, compositionupdate, and compositionend events; and not dispatching keypress events for dead key combinations. Refer to http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboardevents and http://www.w3.org/TR/DOM-Level-3-Events/#events-textevents .

There an error in the implementation of compositionend.

Firefox browsers are not firing textinput events. I believe that this is the only way Firefox will enable JavaScript developers to write code that is OS-independent. This is going to require a more senior Mozilla engineer to give the go-ahead as it will involve the talents of multiple engineers.

It's probably worth tracking Mozilla bug 447757 , as it has a new HTML example attached.

Revision history for this message
Jacobsallan (jacobsallan) wrote :

Bottom Line
==========
There are multiple bugs w/r to keyboard events in Firefox on Linux.

Background
==========
JavaScript events have attributes. Mozilla currently does the following for key and text events:

(1) Assigns values to the attribute keyCode for keyup and keydown events. The assignment is often wrong (null) on Linux.
(2) Assigns values to the attribute charCode for keypress events. The assignment is often wrong (null) on Linux.
(3) Bungles the assignment of attributes to compositionstart and compositionend on Linux

The W3C specification declines to specify what the correct values are for assignments to charCode and keyCode. It makes recommendations for the assignment of two new attributes: char and key. In principal,
these assignments could be made more less operating system and browser independent.

(4) Firefox does not make assignments to either of the new char or key attributes. In the tables below, no attempt is made to indicate the lack of assignment. Assignment of both char and key look relatively easy. The previous draft of the W3C DOM Level 3 Events specification was more challenging.

(5) Firefox dispatches compositionstart and compositionend events on Linux. On Windows the behavior is completely different. This is an OS dependency that is difficult to code around.

(6) W3C calls for a textInput event to get fired after the last keyup. If Firefox implemented this part of the spec then the OS-dependency and browser-dependency it's current implementation is requiring could be made to vanish -- at least for the majority of the applications that listen to the keyboard.

In an earlier post on this topic, operating system inconsistencies had not been determined. Now they are and they are large.

Supporting Data
===============

Mozilla key and text event sequences
Firefox 3.6.10
Test URL: https://bug447757.bugzilla.mozilla.org/attachment.cgi?id=474270

Nominal keyboard sequence (Windows: AltGr 2 e)
Country: Albania
Language: Albania

The tables record the event sequence in the order of occurence.

Windows
=======
keyC charC alt event
17 - F keydown
18 - T keydown
50 - T keydown
50 - T keyup
17 - T keyup
69 - F keydown
- 283 F keypress
69 - F keyup

Linux
=====
keyCcharC alt event
0 - F keydown
- 0 T keypress
0 - T keyup
0 - T keyup
- - T compositionstart
- - F compositionend
69 - F keyup

Revision history for this message
In , Jacobsallan (jacobsallan) wrote :

Still an issue in Firefox version 3.6.10 / Mozilla Firefox for Ubuntu canonical 1.0.
Ubuntu bug 58693 should be moved out of INCOMPLETE state.

Revision history for this message
Thorsten (kdefan) wrote :

The bug persists in Firefox 3.6.13 (with a brand-new profile) on Kubuntu 10.04. It appears to be Firefox-specific, as Opera and Chrome work just fine.

The broken behavior is still the same. Pressing any dead key only triggers »keyup« (where all values are 0). Pressing a non-dead key after that also only triggers »keyup«, with the »which« and »keyCode« properties set to the value of the base key. E.g., pressing dead acute and 'a' yields:

keyup: which=0 keyCode=0 [for the dead acute]
keyup: which=65 keyCode=65 [for 'a']

Pressing dead grave and a or dead circumflex plus a yields exactly the same.

Revision history for this message
Jacobsallan (jacobsallan) wrote :

Mozilla bug 447757. The key events were badly mishandled on Linux.

affects: firefox-3.0 (Ubuntu) → firefox (Ubuntu)
Changed in firefox-3.5 (Ubuntu):
status: Incomplete → Invalid
Revision history for this message
In , Rogeriorc (rogeriorc) wrote :

Mozilla Firefox 20.0 and still don't fires the onKeyPress event.

Revision history for this message
In , thiago.unicamp (thiago-unicamp) wrote :

Firefox 20.0 on Linux, this bug still exists, and it's really annoying blocking my web application to work.

Revision history for this message
In , Javier-puche-u (javier-puche-u) wrote :

It happens still in Firefox 26, at least on Ubuntu (12.04) If you change focus to another window, click and return to the windows, then it works.

Revision history for this message
create3000 (create3000) wrote :

It is still an issue in a current Firefox release. It is not possible to program custom input elements with, for instance, french language support like on this site: http://create3000.de/users-guide/components/keydevicesensor/stringsensor/#example.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.