我正在尝试使用ctrl-right和ctrl-down来浏览器应用程序。在OS X中,这会导致向右移动一个桌面或平铺当前桌面上的所有窗口。我正在尝试使用e.preventDefault();
,但它不起作用;操作系统功能仍在发生。有没有办法覆盖这些功能?
$(document).keydown(function(e) { //For any other keypress event
if (e.which == 39) { //Checking if it's right arrow
if(ctrlPressed == true){
//spread score across kid's standards
e.preventDefault();
var kid = $(':focus').attr('kidid');
var score = $(':focus').val();
$('.SmallInput[kidid='+kid+']').each(function(index) {
ScoreEntry($(this),score);
});
ctrlPressed = false;
}
} else if (e.which == 40) { //down arrow
if(ctrlPressed == true){
e.preventDefault();
//spread score down standard - all kids
var std = $(':focus').attr('stdid');
var score = $(':focus').val();
$('.SmallInput[stdid='+std+']').each(function(index) {
ScoreEntry($(this),score);
});
ctrlPressed = false;
}
}
});
我在这里使用的是在OS X上使用命令键(测试.metaKey()
)和在Windows上使用ctrl。