0
1

More than 3 years have passed since last update.

Aura component でショートカットキーのイベントを得る

Last updated at Posted at 2020-11-30

以前にも作った記憶があるのですが、すっかりやり方を忘れてしまった。
また忘れないように記録しておきます。

コントローラの doInitの中に以下を書くだけ。

doInit : function(component, event, helper) {

   window.addEventListener('keydown', function(e) {
      if (e.key === 'PageUp') {
         alert("PageUp");
      }
   });
},

注意点
コンポーネントが入れ子になっている場合は、子コンポーネントではイベントが取れないので注意です。
親でイベントを拾って、子に渡してあげないとダメです。

0
1
0

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
0
1