是否可以结合使用按键的混合物来发射单个事件?
$(document).keyup(function(e){
if (e.keyCode == 68 && e.keyCode == 69 && e.keyCode == 86) {
alert('oh hai');
}
});
Run Code Online (Sandbox Code Playgroud)
我在Chrome中尝试过,但事件并未触发.
叫我疯了,但我正在编写一个Chrome扩展程序,并希望将D+ E+ V键一起推送到隐藏的开发人员模式.
我正试图让我的控制器观察组合键.为了论证,让我们说:向上向下左下左右b a.无论用户当前在页面的哪个位置,我如何获得角度以查找这些内容?
我有一个使用快捷方式的 angular.js web 应用程序。当我按下任意键时,我会收到 N 个 keydown 事件,然后是 N 个 keyup 事件,其中 N 介于 2 和 5 之间,而我希望它只触发一次。这是我用来捕获键盘事件的代码:
// Controller.js
var allowed = true;
$document.bind('keyup', function (event) {
console.log('keyup');
allowed = true;
});
$document.bind('keydown', function (event) {
if (allowed) {
allowed = false;
var key = event.which || event.keyCode || event.charCode;
console.log('key down: ' + key);
if (key === 32) { // Space bar
$scope.showAll();
event.stopPropagation();
}
else if ($scope.visible.answerButtons === true) {
if (key === 37) { // Left …Run Code Online (Sandbox Code Playgroud)