Skip to content

Commit

Permalink
feat: add keys data to the callback function HotkeysEvent. (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 9, 2023
1 parent 1b813fa commit 42c82b9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dist/hotkeys.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ function eventHandler(event, handler, scope, element) {


if (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91] || modifiersMatch || handler.shortcut === '*') {
handler.keys = [];
handler.keys = handler.keys.concat(_downKeys);

if (handler.method(event, handler) === false) {
if (event.preventDefault) event.preventDefault();else event.returnValue = false;
if (event.stopPropagation) event.stopPropagation();
Expand Down
3 changes: 3 additions & 0 deletions dist/hotkeys.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ function eventHandler(event, handler, scope, element) {


if (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91] || modifiersMatch || handler.shortcut === '*') {
handler.keys = [];
handler.keys = handler.keys.concat(_downKeys);

if (handler.method(event, handler) === false) {
if (event.preventDefault) event.preventDefault();else event.returnValue = false;
if (event.stopPropagation) event.stopPropagation();
Expand Down
3 changes: 3 additions & 0 deletions dist/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@


if (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91] || modifiersMatch || handler.shortcut === '*') {
handler.keys = [];
handler.keys = handler.keys.concat(_downKeys);

if (handler.method(event, handler) === false) {
if (event.preventDefault) event.preventDefault();else event.returnValue = false;
if (event.stopPropagation) event.stopPropagation();
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface HotkeysEvent {
key: string;
keys: number[];
method: KeyHandler;
mods: number[];
scope: string;
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ function eventHandler(event, handler, scope, element) {
|| modifiersMatch
|| handler.shortcut === '*'
) {
handler.keys = [];
handler.keys = handler.keys.concat(_downKeys);
if (handler.method(event, handler) === false) {
if (event.preventDefault) event.preventDefault();
else event.returnValue = false;
Expand Down

0 comments on commit 42c82b9

Please sign in to comment.