Search code examples
javascriptchardom-eventskeycode

Check if keydown event for umlaute


I want to check via eventListener if the pressed key is an umlaut (ä, ö, ü). The problem is that the charCode/keyCode is always 0 and if I am not mistaken the value is also used for some control keys.

I tried tried to parse the e.which of the keyDown to something I can work with, but until now nothing seems to work. It would be nice if I could do something like 'ä'.atCharCode().

Any help? :) Or is it fine and safe to check for the 0?


Solution

  • Found the problem. In Chrome everthing is fine and umlaute are getting the correct charCode. In Firefox on the other hand it seems like there is no real support for umlaute and their charCode is always 0. The FF I tested in was 17.0.1

    So if you want to solve this problem, you have to don't allow events with a e.keyCode/e.which of 0.