views:

445

answers:

1

currently I listen on "Enter" key to start sending a message,

But for multi-byte characters,the "Enter" key is supposed to choose a certain character.

The problem is that I've no idea how to detect whether a user is in the middle of inputting

a multi-byte character,and even if he's in that process,the message will be sent the first

time he presses the "Enter" key.

So the user experience is really strange.

Any one has a solution to this?

If you don't get what I mean above,can try to chat here,

and once you started a conversation,switching to multi-byte mode,

then you'll know what I mean.

the link is here:

http://maishudi.com/OMegle.php

A: 

I'm assuming your reference to multibyte input is a reference to "Input Methods" (or "Input Method Editors" on windows).

Unfortunately there isn't any real solution at the moment -- DOM3 was going to add mechanisms for this but it seems to have dropped this due to the complexity.

Part of the complexity comes from the vastly different behaviour of individual input methods, before you even consider the behaviour discrepancy between browsers. A good example is to just check what key events you receive for a set of behaviour with japanese, korean, and (traditional and simplified) chinese. The browsers cannot avoid this as they are responding to events fired directly by the input editors.

The only things you can really rely on are keyDown events, and even then not so much in opera and firefox -- Safari and IE both provide keyDown events during IME composition, with a charCode of 229, and a keyUp event with a charCode corresponding to the actual key that was pressed.

There is a textInput event, but that is only supported by Safari (and by proxy Chrome should support it as well), but it's not substantially better than standard events anyway :-/

olliej