Skip to content

Commit

Permalink
fix: keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
jgazeau committed Feb 6, 2023
1 parent 8dae917 commit 7a73ae1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion assets/js/theme/init.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { resizeFunctionsList, shortcutsKeys } from './modules/const.min.js';
import {
addElementToModal,
closeModals,
displayModal,
getFirstAncestorByClass,
isPreCopyToEnable,
} from './modules/helpers.min.js';
import { resizeFunctionsList, shortcutsKeys } from './modules/const.min.js';

// VARS //
// MAIN //
document.addEventListener('DOMContentLoaded', function () {
// Manage shortcuts
let keyBuffer = [];
window.addEventListener('blur', () => {
keyBuffer = [];
});
document.addEventListener('keyup', function (e) {
const keyIndex = keyBuffer.indexOf(e.key);
if (keyIndex > -1) {
Expand Down Expand Up @@ -39,6 +42,7 @@ document.addEventListener('DOMContentLoaded', function () {
) {
e.preventDefault();
window[shortcutsKeys[shortcut].function]();
keyBuffer = [];
}
}
}
Expand Down

0 comments on commit 7a73ae1

Please sign in to comment.