Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating keyboard shortcuts for your HTML5 app?

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).

like image 281
MaiaVictor Avatar asked Mar 05 '13 00:03

MaiaVictor


1 Answers

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

$(document).keydown(function(evt){
    if (evt.keyCode==83 && (evt.ctrlKey)){
        evt.preventDefault();
        alert('worked');
    }
});
like image 89
apoq Avatar answered Oct 01 '22 05:10

apoq