comphist / cora

A web-based, token-level annotation tool for non-standard language data
http://www.linguistics.rub.de/comphist/resources/cora/
MIT License
10 stars 6 forks source link

Lemma field w/ autocompletion doesn't accept & and ( in Firefox #21

Closed mbollmann closed 7 years ago

mbollmann commented 9 years ago

Originally reported by: Marcel Bollmann (Bitbucket: mbollmann, GitHub: mbollmann)


In a lemma field with autocompletion, the characters & and ( cannot be entered in Firefox (and presumably Opera).

The reason for this seems to be a difference between the "keydown" and "keypress" events, and the fact that Meio.Autocomplete performs some actions on "keypress" for Firefox and Opera, while using "keydown" for other browsers.


mbollmann commented 9 years ago

Original comment by Marcel Bollmann (Bitbucket: mbollmann, GitHub: mbollmann):


Fixed by fba1eb1

mbollmann commented 9 years ago

Original comment by Marcel Bollmann (Bitbucket: mbollmann, GitHub: mbollmann):


Die Ursache dafür ist anscheinend ein Unterschied zwischen den JavaScript-Events "keypress" und "keydown". Beide Events haben ein Attribut "key". Wenn ich z.B. +3 drücke, um ein § einzugeben, sieht dieses Attribut so aus:

keydown: 3 keypress: §

"keydown" gibt also anscheinend die gedrückte Taste zurück, "keypress" anscheinend das eingegebene Zeichen. Mache ich dasselbe mit einer geöffneten Klammer (+8), bekomme ich:

keydown: 8 keypress: down

WTF?

Ähnliches passiert auch beim Eingeben von & (keypress: up), " (keypress: pagedown) und noch einigen anderen Zeichen. Ich kann mir nicht erklären, wieso das so ist. Sowohl Firefox als auch Chrome verhalten sich so.

Jedenfalls definiert das Autocomplete-Plugin ein eigenes Event, das normalerweise auf "keydown" reagiert, bei Firefox und Opera aber ausdrücklich auf "keypress" hört. Ich weiß nicht, welche Gründe das hat, aber es gibt jedenfalls später im Code eine Sonderbehandlung der Tasten "up" und "down", was zur Folge hat, dass "&" und "(" in Firefox und Opera nicht funktionieren.