LoginSignup
10

More than 5 years have passed since last update.

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

Last updated at Posted at 2015-04-11

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)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10