1

I'm working with creating Rangy nodes in IE for a special feature used in a content-editable div. Trying to make it as global as possible so there is a lot of key handling code to make sure it handles all the various characters, languages, and IMEs correctly. There is one if statement in a function which has one condition "e.charCode" in a series of "or's" for which the if statement is entered. On IE, charCode is undefined but only when typing the Norwegian character å (alt + 134) is charCode actually valid with that character. This throws everything off and deletes the Rangy node completely in the textbox and makes further typing not respond.

My question is why does the å character behave differently then every other ASCII extended character I have tried? And is there any other special case for Germanic languages that is similar to this issue that I should know about?

Sivad
  • 13
  • 2
  • 1
    To make your application or page global, you should not operate on key codes but on characters. In the absence of actual code, it is impossible to tell what exactly is wrong with your code. Note that there is no “ASCII extended” and that the letter “å” could be typed in a multitude of ways, including the use of a keyboard key labelled “Å”. – Jukka K. Korpela Sep 16 '13 at 16:41
  • Use the `keypress` event. See http://stackoverflow.com/a/4285801/96100 – Tim Down Sep 16 '13 at 22:54

1 Answers1

0

For things like this, you want the Javascript Key Event Test Script. It's a simple web page that simply shows you which values are in which event field. That way, you can see the input for your code.

My guess is that you won't find anything exceptional about å when you type it into the test page.

The next step is to write unit tests that create synthetic events and feed these through your code to make sure it behaves correctly.

I know it's very tempting to do this without unit tests. But over time, the code becomes too complex to understand and really odd errors (like the one you describe) creep in.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820