Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keypress event for Japanese text

$(document).ready(function () {
    $("#id").keydown(function () {

    });
})

This code perfectly works for everything(number,alphabet,symbol etc) except Japanese text. On key press it doesn't pass through this event. Does anybody know any solution?

like image 246
sujal Avatar asked Apr 16 '13 05:04

sujal


1 Answers

There's hardly anything you can do. "Japanese text" means an IME, which is a piece of software intercepting the keyboard input and helping you turn it into Japanese text. How this software interacts or doesn't interact with the browser and the browser's Javascript engine depends on the OS, IME, browser and the browser's Javascript engine. On some platforms the keypress is signaled through, in others it isn't. You can try binding to other events like keyup or keypress, some may be signaled even when using an IME.

The best you can do is to make sure you're not depending on keypress events and have fallback options if you can't intercept them; e.g. bind to change events on the text field as well and handle entire text changes, which will be triggered at the end of the IME input.

like image 122
deceze Avatar answered Oct 18 '22 08:10

deceze