$(document).keypress(function(e)
{
switch(e.which)
{
// user presses the "a"
case 97: showViaKeypress("#home");
break;
// user presses the "s" key
case 115: showViaKeypress("#about");
break;
// user presses the "d" key
case 100: showViaKeypress("#contact");
break;
// user presses the "f" key
case 102: showViaKeypress("#awards");
break;
// user presses the "g" key
case 103: showViaKeypress("#links");
}
});
jquery 键盘事件
本文介绍了一种使用JavaScript实现的网页键盘导航方法。通过监听文档的按键事件,当用户按下指定的字母键时,会触发相应的页面跳转效果。具体实现包括为不同的键绑定不同的功能,例如按下'a'键跳转到主页,'s'键跳转到关于页面等。

被折叠的 条评论
为什么被折叠?



