Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
10
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@pazworld

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

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)
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
10
Help us understand the problem. What are the problem?