Is there a way to with jQuery keyCode to detect Command + C? The keycode only sends one key, not the pressed combo. I'm looking to setup a binding to detect Command + C. I've seen some keyboard shortcut plugins but would like to avoid adding an additional library for one simple binding.
you can check the ctrlKey
property of the event. (possibly metaKey
if it's on mac, not sure)
for Ctrl + C
$(document).on("keydown", function(e){
if (e.keyCode == 67 && (e.ctrlKey || e.metaKey)){
//it was Ctrl + C (Cmd + C)
}
});
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