edge
October 8, 2017, 1:25pm
1
Hi,
I want to disable different clicks on website and keyboard shortcuts.
I found example on google regarding disable right key,disable full page etc.
I am looking for any jquery or javascript library for below option
[1]. Disable Right Click
[2]. Disable Ctrl+c
[3]. Disable Ctrl+v
[4]. Disable Ctrl+x
[5]. Disable Ctrl+s
[6]. Disable Ctrl+p
[7]. Disable Ctrl+w
[8]. Disable Ctrl+u
[9]. Disable Ctrl+a
[10]. Disable Ctrl+z
Any idea?
-Thanks
Can I ask why you want to do this, given it will make life difficult or impossible for anybody keyboarding because they can’t use a mouse?
2 Likes
Disable the context menu:
document.addEventListener('contextmenu', event => {
event.preventDefault()
})
Disable essential hotkeys:
document.body.addEventListener('keydown', event => {
if (event.ctrlKey && 'cvxspwuaz'.indexOf(event.key) !== -1) {
event.preventDefault()
}
})
BTW I think you forgot ctrl+r to prevent the user from conveniently reloading the page. No seriously, don’t do that. ^^
edge
October 8, 2017, 2:40pm
4
Hi,
I will not make use of all options to disable but some shortcuts and clicks.
Where I will find details documentation for implementation with require jquery library files.
Hi “m3g4p0p” , I am not getting how this will work from your example code.
How this example code will work for different shortcuts.
Any idea?
I added a keydown
event listener to the whole body. Inside the handler function, I checked whether the control key is pressed (event.ctrlKey
) and the actual .key
is one of cvxspwuaz
, and if so, prevent the default action (which would be copy/pasting etc.). Here’s a fiddle .
system
Closed
January 7, 2018, 9:54pm
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.