mousetrap
mousetrap copied to clipboard
ctrl+tab doesn't fire
I want to use ctrl+tab in my electronjs app. So it is not a browser to interrupt with tab changing shortcut. However when I'm inside a text area it doesn't fire at all. Other shortcuts without tab do. How do I bind the whole document ?
<script>
Mousetrap.bind(['command+tab', 'ctrl+tab'], function() {
alert('command tab or control tab);
// return false to prevent default browser behavior
// and stop event from bubbling
return false;
});
</script>
From the documentation:
Text fields
By default all keyboard events will not fire if you are inside of a textarea, input, or select to prevent undesirable things from happening.
If you want them to fire you can add the class mousetrap to the element.
<textarea name="message" class="mousetrap"></textarea>