I created one Asp.net MVC4 web application using C# which we can dynamically create keyboard shortcuts for all the pages.And we can use that keyboard shortcuts instantly to go to specific page.And the problem is every browser have their own default shortcuts.For example
If I create the keyboard shortcut CTRL + A it should redirect to my own custom page. But the default browser shortcut CTRL + A selects all from the page instead.
I want to disable the default browser shortcuts to give priority to my own custom shortcuts.Is this any way to achieve these? For my custom shortcuts,i used jquery keyUp event.I searched on internet,there suggestion are on jquery keyUp event,use preventDefault().But for accessing my own custom shortcuts,i am using keyUp event.So tell me suggestions to disable default browser shortcuts in all browsers either by C#, jquery or any other way.
This will let you do this:
e.ctrlKey && String.fromCharCode(kc).toUpperCase()
checks for Ctrl + A to be pressed.
$(document).on('keydown', function(e) {
var kc = e.which || e.keyCode;
if (e.ctrlKey && String.fromCharCode(kc).toUpperCase() == "A") {
e.preventDefault();
console.log(String.fromCharCode(kc).toUpperCase());
window.location.href = 'your url here';
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
adfasfasdfsda
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