Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top