How to assign Ctrl-F to activate search field?

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
photolesa
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?

Post by photolesa »

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
AlexFox
Sr. Propeller Head
Posts: 149
Joined: Thu Oct 19, 2017 1:56 am

Re: How to assign Ctrl-F to activate search field?

Post by AlexFox »

Likely something such as;

Code: Select all

window.addEventListener("keydown",function (e) {
    if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) { 
        document.getElementById("X").focus();
    }
})
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.
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: How to assign Ctrl-F to activate search field?

Post by NorthEast »

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.
You could use this instead:

Code: Select all

$(".search-field").focus();
(Instead of: document.getElementById("X").focus(); )
AlexFox
Sr. Propeller Head
Posts: 149
Joined: Thu Oct 19, 2017 1:56 am

Re: How to assign Ctrl-F to activate search field?

Post by AlexFox »

Dave Lee wrote:
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.
You could use this instead:

Code: Select all

$(".search-field").focus();
(Instead of: document.getElementById("X").focus(); )
I'm so shabby with JS, thanks!
Post Reply