ether / etherpad-lite

Etherpad: A modern really-real-time collaborative document editor.
http://docs.etherpad.org/
Apache License 2.0
16.73k stars 2.86k forks source link

Non-working dead keys in Firefox #2539

Closed XoR-42 closed 4 years ago

XoR-42 commented 9 years ago

The use of dead keys to type accents does not seem to work in Firefox. For example typing 'ê' on a french keyboard, or any accent with the layout 'international with dead keys' leads to a character without accent.

It works properly in Chromium though.

Tested on the 'develop' branch locally, on pad.riseup.net and on pad.lqdn.fr. Browsers: Firefox Nightly 39 and Firefox 36 on Linux.

JohnMcLear commented 9 years ago

Please test on http://beta.etherpad.org

Please explain what keystokes are required on a UK keyboard for me to replicate this issue.

XoR-42 commented 9 years ago

Hi, I tested on http://beta.etherpad.org and the issue remains. To my knowledge there are no dead keys on the standard UK layout. However you can reproduce the bug by switching to an international layout with dead keys such as "English (Macintosh)" or "English (UK, international with dead keys)" (these names are how they appear on Gnome) which allow you to type accents using dead keys. For example on the latter, Meta+[ followed by e should produce the character ë (Meta is usually mapped on right alt key). You can also try the french layout that has a dead key for ^ (the [ key on a standard qwerty keyboard): [ followed by e should produce the character ê.

Thanks for the work done on this wonderful piece of software. Best regards,

XoR

JohnMcLear commented 9 years ago

Works fine for me (English Macintosh) Alt Gr+ [ + e inserts ë in FF 36 on https://beta.etherpad.org/p/31h77r9uyI

XoR-42 commented 9 years ago

I just re-tested across several OSs and it seems to work with Firefox 36 on OSX (10.8.5) and with Firefox 34 on Windows (Server 2008). I'm only able to reproduce on Linux systems (Debian, Archlinux, Ubuntu) with different desktop environments (Gnome, Enlightenment, Unity).

JohnMcLear commented 9 years ago

I tested FF 36 on Ubuntu FYI -_- ;/

XoR-42 commented 9 years ago

I just retried with Firefox 35 on Ubuntu + Unity, french keyboard and I was still unable to type a ê. It starts looking like a Heisenbug :/ EDIT: after updating to Firefox 36, I'm still able to reproduce...

JohnMcLear commented 9 years ago

What key do you have bound to Meta?

XoR-42 commented 9 years ago

On my current machine (macbook pro running Gnome/Arch) with the "English (Macintosh)" layout, it's the right alt key. meta+e followed by e produces é, meta+` followed by a gives à etc. For the tests on the other machines I used the french layout and tried [ followed by e that is expected to produce ê (no meta key) or shift+[ followed by i that should produce ï.

XoR-42 commented 9 years ago

By polling around, I found a Mint+Firefox 35+Gnome and a Gentoo+Firefox 31+xfce that do not exhibit the issue (french keyboard both of them)... We also tried with a clean Firefox profile without any addon on one of the affected machines and it didn't help, so I think we can rule out that explanation :/

XoR-42 commented 9 years ago

I tried to reproduced in a controlled environment. I ran untouched Ubuntu live isos in kvm-qemu virtual machines, added the french layout and tried to type ê with the virtual keyboard (onboard) - to avoid any interference linked to hardware or emulation - into a pad on http://beta.etherpad.org.

With the 14.10 iso everything's fine, after updating firefox too. With the 15.04 daily build (http://cdimage.ubuntu.com/daily-live/current/) the bug appears and the dead keys to produce ê and ë characters do not work.

I hope that it will help to circumvent the bug, I'll try to find the time to dig into the code to understand its origin in the following weeks.

Best regards.

XoR

JohnMcLear commented 9 years ago

It sounds like the bug might be an OS bug if it's fine in 14.10 but not in 15.04.. I can try update my instances to 15.04 to see if I can create it..

XoR-42 commented 9 years ago

I spotted a js warning in the console that seems related: KeyboardEvent.key values starting with "Dead" are obsolete and will be merged into just "Dead". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key I'm trying to find where the code responsible for the KeyboardEvent is.

JohnMcLear commented 9 years ago
jose@jose-healthy:~/etherpad-lite/src/static/js$ grep -rni dead .
jose@jose-healthy:~/etherpad-lite/src/static/js$ cd ..
jose@jose-healthy:~/etherpad-lite/src/static$ grep -rni dead .
jose@jose-healthy:~/etherpad-lite/src/static$ 

No our code?

JohnMcLear commented 9 years ago

ace2_inner.js handles key inputs btw.. And special keys..

tgirod commented 9 years ago

Same problem here with firefox 37 on archlinux. My keyboard layout is altgr-intl, which uses dead keys quite a lot.

JohnMcLear commented 9 years ago

@tgirod Can you please provide exact steps to replicate? What key press combo are you using?

tgirod commented 9 years ago

any accent followed by a letter will miss the accent. For example:

alt- + ewill give meeinstead ofè. alt-^ + awill give meainstead ofâ`

but alt-e will give me é as it should.

JohnMcLear commented 9 years ago

Installing Arch linux on a VM to test.

JohnMcLear commented 9 years ago

Alt-` does nothing for me.. Alt E brings up the Edit menu...

tgirod commented 9 years ago

okay, my bad. As I said earlier, my keyboard layout variant is altgr-intl. This turns the right alt key into AltGr. To see my problem, you have to set the XKbVariant (see my xorg.conf excerpt below) and use the right alt key.

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us"
        Option "XkbOptions" "terminate:ctrl_alt_bksp"
    Option "XkbVariant" "altgr-intl"
EndSection
morallo commented 9 years ago

I am suffering the same problem with a Spanish keyboard, which uses dead keys for accents (´,`,^,¨) If I type the dead key and then the character key at a normal pace, the accent is "lost" and I get "a" instead of "á".

However, if I do it quickly enough, the accent is preserved. It feels like if Etherpad does not have time to sync in between the pressing of the two keys, the input interprets the character code correctly.

My specs: Ubuntu 14.04 LTS, Firefox 37.0.1

JohnMcLear commented 9 years ago

Perhaps someone with a Spanish keyboard would be best to debug this. I'm simply unable to replicate the problem with my current setup.

morallo commented 9 years ago

Could you try this?

  1. Change keyboard config to Spanish 2 Open a terminal or text editor
  2. Press and release the "'" key (two keys to the right from the L key, just besides the enter key).
  3. Press and release the "a" key. You should get "á" printed on screen.
  4. Repeat in etherpad-lite.
  5. Find out why it didn't work ☺

Let me know if I can try anything for debugging.

JohnMcLear commented 9 years ago

No need for alt gr?

JohnMcLear commented 9 years ago

Weirdly I can sometimes get â to show in the editor but it's not consistent..

JohnMcLear commented 9 years ago

Looks like it's something in handleKeyEvent that is preventing the expected behaviour..

JohnMcLear commented 9 years ago

At least this is the way to replicate this behaviour consistently. I spent 25 mins on a fix to no avail. Alt Gr ' e works fine.. Alt Gr ' a does not work.. *boggles.

morallo commented 9 years ago

No alt-gr needed for Spanish keyboard accents. For me, the behaviour depends on your quickness. If you press both keys with a short enough period in between, it works. Try withoug AltGr, it's probably easier to be quick enough.

JohnMcLear commented 9 years ago

Well if I do ' then a I get 'a as a text string...

morallo commented 9 years ago

Did you switch your keyboard layout to Spanish?

JohnMcLear commented 9 years ago

yep.

morallo commented 9 years ago

Do you get a Ñ if you press ; key?

JohnMcLear commented 9 years ago

No I get ; afaik, that device upstairs now.

morallo commented 9 years ago

Then your kb layout is not changed, I'm afraid :-)

JohnMcLear commented 9 years ago

I tried changing each timed based event to increase by a factor of 10 and it did not make any difference which means it is something to do with a way we are handling keypresses assuming we are firing the wrong type of event on either keydown or keypress

JohnMcLear commented 9 years ago

This bug existed in old versions of Etherpad too so we might have to write some new logic handling.

JohnMcLear commented 9 years ago

Give this a go guys.. https://github.com/ether/etherpad-lite/tree/fix-dead-keys

JohnMcLear commented 9 years ago

Any dice anyone?

git checkout fix-dead-keys to get the branch! :)

XoR-42 commented 9 years ago

Hi, the patch seems to fix the issue for me when I'm using the french keyboard (to type ï and î for example), but the issue remains with the "english (macintosh)" keyboard and the combinations of keys including meta (meta+e e to get é, meta+` e to get è etc.)...

Well done for the partial fix at least!

JohnMcLear commented 9 years ago

I'd want to open a separate issue for Mac and keep that out of this one.

morallo commented 9 years ago

It's an improvement, but does not fix the problem at normal typing speed. If you type ´ and then a, you get the right á. However, if you type a+´+a, you sometimes get aa, instead of . The behaviour is inconsistent. Again, it seems like some kind of sync timing issue.

XoR-42 commented 9 years ago

I don't think it's specific to mac, but rather general to the layouts using meta keys: I'm using this layout on a thinkpad which exhibits the same error.

JohnMcLear commented 9 years ago

@morallo yeah I can replicate that issue. I tried modifying all the timings that are set on key events and it doesn't effect the behaviour. Not sure what to suggest for that right now.

Dead keys seem to work fine for me now @XoR-42 . I tried your French example and got ê which was expected.

tgirod commented 9 years ago

It didn't change anything with my us altgr-intl keyboard layout. Just in case I missed something, here is what I did:

git clone https://github.com/ether/etherpad-lite.git
cd etherpad-lite
git checkout fix-dead-keys
bin/run.sh
JohnMcLear commented 9 years ago

looks right @tgirod I will test your stuff later today if I can

XoR-42 commented 9 years ago

@tgirod @JohnMcLear , that was what I was trying to explain, the fix seems to do the job for the "standard" dead keys, but doesn't seem to work for dead keys typed with a combination of meta+another key (like my "english (macintosh)" example or @tgirod 's "altgr-intl" example).

@JohnMcLear : "Dead keys seem to work fine for me now @XoR-42 . I tried your French example and got ê which was expected." That's what I was saying at 11pm yesterday, it works fine with the french keyboard (dead keys without modifiers) but not with the "english (macintosh)" layout (dead keys typed with combination involving meta, nothing to do with mac hardware).

JohnMcLear commented 9 years ago

I'm testing w/ Mac Kb doing AltGr + e then e which should give é and I can replicate the problem. The weird hting is jQuery is returning false for META key... I don't seem to get the metaKey boolean to trigger true on meta key values on any browsers.. I think I may be either on the wrong path or doing something wrong.. Can someone please test http://api.jquery.com/event.metakey/ and see if they can get it to return true?

I think maybe there has been some confusion between dead keys and meta keys in this thread..

JohnMcLear commented 9 years ago

Spent some more time on this today and didn't make much progress.. Will try later in the week..

pyropeter commented 9 years ago

I can still reproduce this problem on https://beta.etherpad.org/, but it is possible to input dead keys if you are quick. It's actually kind of usable for me, because I type quite fast, but it might be unusable for others and is certainly an usability nightmare.

I'm using the US International keyboard layout. ArchLinux, Firefox 38.0.

Steps to reproduce:

  1. run in terminal: setxkbmap us intl
  2. enjoy all the nice umlauts in every other text input, like ö, ä, ẽ, etc. (you can input these by pressing ", ', ~, ^ or ` and then a compatible character (like a, o, u, sometimes e).
  3. go to https://beta.etherpad.org/ and try it there
brauliobo commented 9 years ago

+1, same as @pyropeter