I am using Mousetrap for create keyboard shortcuts, it was not working when any fields in focus. This is the link for view demo http://davidwalsh.name/keyboard-shortcuts from where i get the code. when i use to call
Mousetrap.bind('ctrl+m', function () {
var button = $('[data-action="next-page"]');
if (button.length) {
button[0].click()
}
});
like this it not working , when mouse points in text-box or drop-down etc,. Can any give solution for me. Thanks in advance.
By default mousetrap disable the shortcuts when the focus is on input fields, dropdown, etc..
If your problem is with only one field, include the class mousetrap
in it.
If you want to disable all scenarios try the following code
Mousetrap.stopCallback = function () {
return false;
}
This will overwrite the initial behavior and allow shortcuts in any field of the screen.
If you're using input or textarea or select elements, you must define the mousetrap class:
<textarea name="message" class="mousetrap"></textarea>
See the "Text fields" section in the oficial doc at https://craig.is/killing/mice
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With