最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Creating keyboard shortcuts for your HTML5 app? - Stack Overflow

programmeradmin4浏览0评论

How to create keyboard shortcuts for HTML5 apps? Using key events don't work because some browsers already define most of those inputs for built-in features such as Save As..., (which are useless for interactive apps).

How to create keyboard shortcuts for HTML5 apps? Using key events don't work because some browsers already define most of those inputs for built-in features such as Save As..., (which are useless for interactive apps).

Share Improve this question asked Mar 5, 2013 at 0:52 MaiaVictorMaiaVictor 53k47 gold badges157 silver badges301 bronze badges 1
  • 4 You have to show what you've tried, and what you don't like, there are plenty of shortcuts that aren't taken up by the browser... – Ruan Mendes Commented Mar 5, 2013 at 1:02
Add a ment  | 

2 Answers 2

Reset to default 12

Well, that one works for me: (CTRL-S in Chrome)

$(document).keydown(function(evt){
    if (evt.keyCode==83 && (evt.ctrlKey)){
        evt.preventDefault();
        alert('worked');
    }
});

try giving this a look.

http://www.openjs./scripts/events/keyboard_shortcuts/#add_docs

sample to add shortcut

shortcut.add("Ctrl+B",function() {
alert("Bold");});

sample to remove shortcut

shortcut.remove("Ctrl+B");
发布评论

评论列表(0)

  1. 暂无评论