0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

rooksのuseKeyでShift+Keyを使用したい

Posted at

結論
仮に、shift + kキーの処理を行いたい場合。
shift + kではなく大文字のKとする。

useKey("K", (e) => {
  // ここに処理
});

あるショートカットキーを実装しているときに、Shift+kキーを処理したいときがありました。
useKeysを使用して、["Shift", "k"]としても効果がありません。
kから先に押してShiftならいけるのに……。なぜ……。と思ったら。
e.shiftkeyとかにそもそもたどり着けない。

useEffectでonKeyPressを取得していろいろ調べていると、そもそも大文字Kとして処理されていることが判明。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?