JavaScript and keyboard shortcuts

I’ve been scouring the internet all day trying to find an answer, and I believe it’s no but I turn to the trusty old Kirupa forms for the definitive answer.

Is it possible to create a function that is triggered when a user presses Ctrl + F? I’ve created custom keyboard shortcuts with JavaScript before and I’m not trying to disable the find feature I’d just like it to be accompanied by something else.

The specific use case: I have several drop downs on a page with content, when clicked they open up and the content is shown. However when the drop downs are closed the content is not searchable. So I was thinking it would be nice if all the drop downs opened when the user hit Ctrl + F so that everything on the page was searchable.
I realize there may be more effective ways to do this but I’m implementing this on a fairly closed corporate network so it really has to be a front end solution.

Yes. Listen for keyup and keydown events, then read the events’ key property.

This tutorial covers how to detect multiple keyboard presses as well: https://www.kirupa.com/html5/keyboard_events_in_javascript.htm

Oh duh! Thanks you two. I was using the “keypress” listener vs “keydown” so I couldn’t get the Ctrl to work.