Solution 1 :

You can try using keystroke events. On keystroke, alert the user & return false.

Reference :

Disable Shortkeys when Ctrl or Shift clicked`

Problem :

When I am on IE, when I use tab to move my focus to the link and press CTRL+Shift+Enter, I get the page opened in another tab. I want to restrict this behavior on IE and show the message to user like “not supported”, please suggest me how to achieve this using javascript.

Comments

Comment posted by marekful

Why are you pressing CTRL and SHIFT?

Comment posted by Raman

This is just to restrict the user from opening a new tab when user presses CTRL+Shift+Enter

Comment posted by marekful

You can listen for keyup and keydown events, detect when CTRL or SHIFT is pressed or released and keep track of their states (i.e. ctrl-down=true|false). Then on the links you want this behaviour, listen for click and keydown(enter) events and preventDefault() when CTRL or SHIFT is down, then change location to the link’s href.

Comment posted by medium.com/@maheshkariya/…

I suggest you refer this link may give you the idea of how to disable keys using Javascript. Ref:

By

Leave a Reply

Your email address will not be published. Required fields are marked *