Help us understand the problem. What is going on with this article?

Handsontableで日本語入力関連キーを無視する

More than 5 years have passed since last update.

Handsontableで漢字キーなどの日本語入力関連キーを押すとセルへの入力開始とみなされ、既存のセル内容がクリアされてしまいます。

漢字キー.png

以下のようにすることで、日本語入力関連キーを無視させることができます。

ignoreimekey.js
var hot = new Handsontable(container, {
  // ...
  // Handsontableのオプション指定
  // ...
});

hot.updateSettings({
  beforeKeyDown: function (e) {
    if ([28,29,241,242,243,244].indexOf(e.keyCode) >= 0) {
      e.isImmediatePropagationEnabled = false;
      e.isImmediatePropagationStopped = function(){
        return true;
      }
    }
  }
});

jsFiddleのデモ

以下のキーを無視しています。

  • 変換 (28)
  • 無変換 (29)
  • カタカナ (241)
  • ひらがな (242)
  • 漢字キー (243, 244)
pazworld
ヘボプログラマです。Erlangがマイブームです。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした