I'm trying to create shortcuts on the website I'm making. I know I can do it this way:
if(e.which == 17) isCtrl=true;
if(e.which == 83 && isCtrl == true) {
alert('CTRL+S COMBO WAS PRESSED!')
//run code for CTRL+S -- ie, save!
e.preventDefault();
}
But the example below is easier and less code, but it's not a combo keypress event:
$(document).keypress("c",function() {
alert("Just C was pressed..");
});
So I want to know if by using this second example, I could do something like:
$(document).keypress("ctrl+c",function() {
alert("Ctrl+C was pressed!!");
});
is this possible? I've tried it and it didn't work, what am I doing wrong?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…