Skip to content

Commit

Permalink
Fixed AnalyseAll shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Sep 28, 2024
1 parent 14378dd commit 677966e
Showing 1 changed file with 20 additions and 35 deletions.
55 changes: 20 additions & 35 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2353,34 +2353,25 @@ function onChartData(args) {
}

function handleKeyDown(e) {
let action = e.key//, button = e.key;
// navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => {
// for (let [key, val] of keyboardLayoutMap.entries()) {
// if (val === button) {
// action = key;
// }
// }
// // Not found? Use e.code
// action ??= e.code;
console.log(`${action} key pressed`);
if (action in GLOBAL_ACTIONS) {
contextMenu.classList.add("d-none");
if (document === e.target || document.body === e.target || e.target.attributes["data-action"]) {}
const modifier = e.shiftKey ? 'Shift' : e.ctrlKey ? 'Control' : e.metaKey ? 'Alt' : 'no';
trackEvent(config.UUID, 'KeyPress', action, modifier );
GLOBAL_ACTIONS[action](e);
}

[].forEach.call(document.querySelectorAll('[data-action]'), function (el) {
el.addEventListener('click', function (e) {
let action = e.currentTarget.dataset.action;
if (action in GLOBAL_ACTIONS) {
e.preventDefault();
GLOBAL_ACTIONS[action](e);
}
});
let action = e.key;
config.debug && console.log(`${action} key pressed`);
if (action in GLOBAL_ACTIONS) {
contextMenu.classList.add("d-none");
if (document === e.target || document.body === e.target || e.target.attributes["data-action"]) {}
const modifier = e.shiftKey ? 'Shift' : e.ctrlKey ? 'Control' : e.metaKey ? 'Alt' : 'no';
trackEvent(config.UUID, 'KeyPress', action, modifier );
GLOBAL_ACTIONS[action](e);
}

[].forEach.call(document.querySelectorAll('[data-action]'), function (el) {
el.addEventListener('click', function (e) {
let action = e.currentTarget.dataset.action;
if (action in GLOBAL_ACTIONS) {
e.preventDefault();
GLOBAL_ACTIONS[action](e);
}
});
// });
});
}


Expand Down Expand Up @@ -2581,14 +2572,8 @@ function onChartData(args) {
/////////// Keyboard Shortcuts ////////////

const GLOBAL_ACTIONS = { // eslint-disable-line
a: function (e) {
if ( e.ctrlKey || e.metaKey) {
if (currentFile) {
if (e.shiftKey) document.getElementById('analyseAll').click();
else document.getElementById('analyse').click()
}
}
},
a: function (e) { ( e.ctrlKey || e.metaKey) && currentFile && document.getElementById('analyse').click()},
A: function (e) { ( e.ctrlKey || e.metaKey) && currentFile && document.getElementById('analyseAll').click()},
c: function (e) {
// Center window on playhead
if (( e.ctrlKey || e.metaKey) && currentBuffer) {
Expand Down

0 comments on commit 677966e

Please sign in to comment.