im using this code which i found here, on a stackoverflow post for keypress combination:
$(document).keypress("c",function(e) {
if(e.ctrlKey) {
alert('Combined');
}
});
The thing is, i'm not sure what is the meaning of the "c", but this code will alert only on Ctrl+z, and i've tried to replace that "c", but still it only works on Ctrl+z.
This is where i found that code: jquery: keypress, ctrl+c (or some combo like that)
Why is that?
this code will alert only on Ctrl+z, and i've tried to replace that "c", but still it only works on Ctrl+z
That's not true. This code works on any combination Ctrl+[key].
So your issue cannot be reproduced.
Regarding to "c"
as the first argument of .keypress
method: According to manual the first argument ("c"
in your case), if present, is passed to the event handler as property data
of Event
object.
So you can access it by e.data
notation in your event handler (see Demo).