mousetrap icon indicating copy to clipboard operation
mousetrap copied to clipboard

ctrl+tab doesn't fire

Open donnydarko opened this issue 3 years ago • 1 comments

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>

donnydarko avatar Jun 28 '21 17:06 donnydarko

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>

j-applese3d avatar Oct 26 '21 16:10 j-applese3d