You have to use the keydown function to trap Ctrl characters. Here is my implementation of Ctrl+A:
$(document).keydown(function(e) {
if (e.keyCode == 65 && e.ctrlKey) {
alert('ctrl A');
}
});
Ctrl-R is tougher because in most browsers, that is Reload Page, which means the javascript doesn't run, the page is refreshed.
Just a note as well, the keyCode value are different in the keydown/keyupup functions than in the keypress functions.
EDIT: Removed ctrl variable, forgot about ctrlKey
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…