Javascript keaboard events for function keys f1 to f12

Using the function keys in a web application is a dicey situation.  Several of the keys have specific uses in the browser and these keys should be avoided at all costs.  Additionally, the keys all have a semantic meaning in the UI standards of various operating systems.  But if you insist on using function keys, here’s a handy matrix for how they map and what events they can be used from.

Key Windows Semantic Meaning onKeyDown onKeyPress* onKeyUp Notes
F1 Help 112 112 N/A Don’t use this, it will open the browser’s help regardless of the way you process this key.
F2 Undo 113 113 113
F3 Redo 114 114 N/A
F4 New 115 115 115
F5 Open/Refresh N/A N/A 116 Don’t use this… ever.  It always refreshes the browser and this functionality cannot be overridden.
F6 Close 117 117 N/A
F7 Reply 118 118 N/A In Firefox this brings up the dialog to turn off caret browsing.  You should avoid this key.
F8 Forward 119 119 119
F9 Send 120 120 120
F10 Spell 121 121 121
F11 Save/Full Screen 122 122 122 DON’T USE THIS!  This causes the browser to go full screen (just about all browsers have this now).  The semantic meaning of Save should be transferred to F6 which is semantically Close by default.
F12 Print 123 123 123

* IE does not support the onKeyPress event for function keys!

You’ll notice several keys don’t show up in the onKeyUp event.  I have no idea why this behavior exists.


Popular posts from this blog

Restore the lost focus of Auto post back controls in update Panel control

Disable backspace key using Jquery

Clone a generic list in C# using extension method

Angular User Session Timeout example step by step

Add Comma automatically while entering amounts in textbox using Javascript

Send bulk Email in using excel file

Remove Owin from MVC 5 Application and use custom forms authentication

How to Import CSV File and bind csv file data to gridview in using c#

Implement Nlog in .Net core MVC application part 1