I agree with William that in general it is a bad idea to hijack the function keys. That said, I found the shortcut library that adds this functionality, as well as other keyboard shortcuts and combination, in a very slick way.
Single keystroke:
shortcut.add("F1", function() {
alert("F1 pressed");
});
Combination of keystrokes:
shortcut.add("Ctrl+Shift+A", function() {
alert("Ctrl Shift A pressed");
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…