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

127
Views
js mac overwrite keyboard shortcut

default Mac keyboard shortcut in safari, I want to overwrite them. such as cmd+s, cmd+n

let isMeta = false;
    window.onkeydown = e => {
        if(e.key == "Meta"){
            isMeta = true;
        }else if(e.key == 's' && isMeta){
            e.preventDefault();
            console.log('s');
        }else if(e.key == 'n' && isMeta){
            e.preventDefault();
            console.log('n');
        }
    };
    window.onkeyup = e => {
        if(e.key == "Meta"){
            isMeta = false;
        }
    };

testing result: cmd+s succeeded, when I press the shortcut, saving action is prevented and s is logged. but ctrl+n will call default opening new tab and n is not logged.

I wonder why this happens, why one works but the other.

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!