In my web app I want to use ctrl+alt+c as hotkey.
I read bunch of Stack Overflow articles and came up with below solution
$(document).keydown(function(e){
if(e.ctrlKey && e.altKey && e.which == 99){
e.preventDefault();
window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
}
});
This is not working in chrome. I tried debugging.
What I noticed is as soon as I press ctrl key it goes into function and as if condition fails it is coming out.
How can I get this to work.
Use the event
keypress
instead. Example on jsFiddle.There are two mistakes in you code
So the final code would be
you can check the fiddle here