Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding browser shortcuts? #40

Open
NathanWailes opened this issue Oct 12, 2018 · 8 comments
Open

Overriding browser shortcuts? #40

NathanWailes opened this issue Oct 12, 2018 · 8 comments

Comments

@NathanWailes
Copy link

NathanWailes commented Oct 12, 2018

Thank you for creating this library, it's extremely easy to use and very helpful!

I wanted to set a shortcut to 'ctrl+t', but when I tested it in Chrome, it opened a new tab instead.

Is there any way to override browser shortcuts?

If not, is there a list of all browser shortcuts across all browsers, so I can know which shortcuts aren't already being used by one or more browsers?

@jaywcjlove
Copy link
Owner

@NathanWailes

I thought about implementing the method, but I realized the part.

Press ctrl + r to prevent the browser from refreshing and performing other operations. But ctrl + t does not work.

You can try switching to another combined shortcut.

@davemerrill
Copy link

Similarly, on a Mac, command-option-left-arrow and command-option-right-arrow don't work. I think those events are handled at a very low level, javascript doesn't see them, and can't preventDefault(). I'm not aware of any away around that, but wish for one.

@jaywcjlove
Copy link
Owner

@davemerrill The command + option + left shortcut is occupied by the browser.

@harithakusampudi
Copy link

harithakusampudi commented Nov 15, 2019

I would like to override command + p shortcut and to print in particular, How can i override default print shortcut option.

@jaywcjlove
Copy link
Owner

@harithakusampudi

example: https://codepen.io/jaywcjlove/pen/pooQVEr?editors=1010

hotkeys('command+p,ctrl+p', function(event,handler) {
  event.preventDefault(); 
  console.log('handle', handler.key,  event)
});

@TranVanKung
Copy link

@jaywcjlove thanks. It works. I use event.preventDefault(); to disabled short cut of browser or computer

@jason076
Copy link

@jaywcjlove thanks. It works. I use event.preventDefault(); to disabled short cut of browser or computer

This does not work for ctrl + t in chrome. The handler doesn't get called, thus event.preventDefault() is never reached.

@Bublade
Copy link

Bublade commented Apr 10, 2020

@jaywcjlove thanks. It works. I use event.preventDefault(); to disabled short cut of browser or computer

This does not work for ctrl + t in chrome. The handler doesn't get called, thus event.preventDefault() is never reached.

some shortcuts can't be overriden:
liftoff/GateOne#290 (comment)
https://stackoverflow.com/a/15913471/5599948
https://groups.google.com/a/chromium.org/forum/?fromgroups=#!topic/chromium-bugs/Ntc1byZXHfU

I came across the same problem we just have to live with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants