Yes:
$(document).click(function(e) {
if (e.shiftKey) {
alert("shift+click")
}
});
You can check the event.shiftKey boolean property.
$(selector).click(function(event) {
if (event.shiftKey) {
//....
}
});
Worth note:
to detect Ctrl or "Meta" (Cmd key on OS X)
$(document).click(function(e)
{
if (e.ctrlKey)
{
alert("ctrl+click");
}
});
$(document).click(function(e)
{
if (e.metaKey)
{
alert("CMD+click");
}
});
If I understand your question correctly, you can use the shiftKey
property of the event
object that you receive in your click
handler to check whether the shift key was down when the user clicked.
EDIT: shiftKey
, not shift
A nice library to handle key press events is shortcut.js, available here. It is very good.
You can even capture Crtl+Shift at the same time which is something I was looking for.
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