【问题标题】:how to have combination of keypress in jquery [duplicate]如何在jquery中组合按键[重复]
【发布时间】:2014-02-13 10:29:08
【问题描述】:

我必须在页面上获得按键组合。我写了一个代码

$(document).keydown(function (e) {
    if (e.which == 16 && e.which == 48) {
        alert('hi');
    }
}

但不工作。 如何获得两个或多个键的组合?

【问题讨论】:

  • 谢谢,一切正常。

标签: javascript jquery


【解决方案1】:

你可以使用 e.shiftKey

$(document).keydown(function (e) {
    if (e.keyCode == 48 && e.shiftKey) {        
        alert('hi');
    }
});

DEMO

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-27
    • 1970-01-01
    • 2023-04-08
    • 2012-08-09
    • 2014-03-17
    • 2022-06-14
    • 2015-08-24
    相关资源
    最近更新 更多