How to assign Ctrl-F to activate search field?
-
- Jr. Propeller Head
- Posts: 5
- Joined: Wed Nov 23, 2016 4:04 pm
- Location: Boulder, CO
- Contact:
How to assign Ctrl-F to activate search field?
In HTML5 tripane output, I'd like to hook the keyboard shortcut of Ctrl-F to the search field. That way, when the Help window has focus, you can hit Ctrl-F to put focus on the field so the user can begin typing. Thanks!
-Lesa Snider
http://www.TAITTowers.com: Software technical writer/trainer
http://www.PhotoLesa.com: Author of 14 books and over 40 video courses
http://www.TAITTowers.com: Software technical writer/trainer
http://www.PhotoLesa.com: Author of 14 books and over 40 video courses
Re: How to assign Ctrl-F to activate search field?
Likely something such as;
Where X is the div ID of the search field. I don't believe Flare sets an ID on this field so you'd likely have to do it manually somewhere.
Code: Select all
window.addEventListener("keydown",function (e) {
if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) {
document.getElementById("X").focus();
}
})
Re: How to assign Ctrl-F to activate search field?
You could use this instead:AlexFox wrote:Where X is the div ID of the search field. I don't believe Flare sets an ID on this field so you'd likely have to do it manually somewhere.
Code: Select all
$(".search-field").focus();
Re: How to assign Ctrl-F to activate search field?
I'm so shabby with JS, thanks!Dave Lee wrote:You could use this instead:AlexFox wrote:Where X is the div ID of the search field. I don't believe Flare sets an ID on this field so you'd likely have to do it manually somewhere.(Instead of: document.getElementById("X").focus(); )Code: Select all
$(".search-field").focus();