PDA

View Full Version : Capture F1 key



sanjay_1985
10 Feb 2014, 11:00 PM
Hi All,
Can somebody tell me how do we capture F1 key press on a field in Ext js 4.2?
I am able to capture F2 and few other function keys but not F1. F1 opens browser help.

evant
11 Feb 2014, 1:52 AM
Browsers won't allow you to override some hotkeys. Seems like F1 is one of them.

sanjay_1985
11 Feb 2014, 2:16 AM
Thanks Evan. How do I attach a listener to all fields in a form in a single statement?
I think we can do something like this
Ext.each(Ext.query('???', ???), function(el) { el.on('click', fn); });

Can you tell me what should I give instead of question mark?

palakurthivishal
11 Feb 2014, 3:09 AM
Hello Sanjay,
I guess you need this,

Ext.each(form.getFields(), function(field) { field.on('click', fn); });

pkg
20 Aug 2014, 12:26 AM
Sanjay,

You can disable the default help function in IE using the following two lines

document.onhelp = new Function("return false;");
window.onhelp = new Function("return false;");

Attach keyup event listener to all the fields and do what you want in the handler.

Look at this post on dynamicdrive.com for how to handle F1 key

http://www.dynamicdrive.com/forums/showthread.php?47959-Disable-browser-F1-and-replace-with-own-content