Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
Detect Cmd + F or ctrl + F to focus an input

I'd like to focus a search input on my Vue-based website using a shortcut like CMD + F on macOS or CTRL + F on Windows/Linux.

As shown in Check if Shift + letter is pressed in JS / Vue 2, a snippet like

document.onkeydown = function(e) {
  if (e.shiftKey && e.keyCode >= 46 && e.keyCode <= 90) {
    console.log("SHIFT + " + e.keyCode);
    return false;
  }
}

works fine for Shift etc., but I can't console.log out CMD so I don't really know how to proceed here.

A nice example (with CMD + K) is shown here: https://vee-validate.logaretm.com/v4/

So my questions:

  • What are the best ways to focus an input using a shortcut? I guess I'd always have to determine the OS family to check, whether I'd have to listen for CMD or CTRL?
  • Are there any libs for that?
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!