用jquery覆盖ctrl-arrows

问题描述 投票:1回答:1

我正在尝试使用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;
    }
  }
});
javascript jquery
1个回答
0
投票

我在这里使用的是在OS X上使用命令键(测试.metaKey())和在Windows上使用ctrl。

© www.soinside.com 2019 - 2024. All rights reserved.