Support for keyboard shortcut disabling to prevent accidental key presses.
1 Like
Yes, please! I need this feature, as the shortcuts (at least for me) are working suboptimal. Quite often, while for example updating a task’s description, some shortcut is wrongly triggered. This leads to an issue being updated in ways I did not want.
I installed the Violentmonkey addon, and started using the script below to disable all shortcuts. Only tested it for a couple of hours, but seems to work OK.
(function() {
'use strict';
function isEditable(element) {
if (!element) return false;
if (element.isContentEditable) return true;
const tag = element.tagName;
return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
}
function stopEvent(e) {
if (!isEditable(document.activeElement)) {
e.stopImmediatePropagation();
e.preventDefault();
return false;
}
// Allow normal typing in editable fields
}
window.addEventListener('keydown', stopEvent, true);
window.addEventListener('keyup', stopEvent, true);
window.addEventListener('keypress', stopEvent, true);
})();
For the record, this seems to work pretty well (enabling arrow keys and enter):
(function() {
'use strict';
function isEditable(element) {
if (!element) return false;
if (element.isContentEditable) return true;
const tag = element.tagName;
return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
}
function stopEvent(e) {
// Always allow ENTER and arrow keys
const allowedKeys = [
"Enter", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"
];
if (allowedKeys.includes(e.key) ||
[13, 37, 38, 39, 40].includes(e.keyCode)) {
return;
}
if (!isEditable(document.activeElement)) {
e.stopImmediatePropagation();
e.preventDefault();
return false;
}
// Allow normal typing in editable fields
}
window.addEventListener('keydown', stopEvent, true);
window.addEventListener('keyup', stopEvent, true);
window.addEventListener('keypress', stopEvent, true);
})();