Entry
how to disable ctrl c and ctrl v in a text area, but still allow user to type in text box
Dec 28th, 2005 03:27
b w, Sherry Jensen, Martin Honnen - http://www.faqts.com/knowledge_base/view.phtml/aid/1115/fid/145, http://www.intranetjournal.com/ix/msg/27033.html
I 'm answering my own question, but when I figured it out, I thought
others would like to know.
This will disable the control key from being pressed at all. It can be
modified to disable any key as long as you know they keyCode. (Not sure
if it works in Netscape.)
<script>
function validateKey (evt)
{
if (evt.keyCode == '17')
{
alert("You may not cut and paste text here.")
return false
}
return true
}
</script>
within the body:
<INPUT TYPE="text" NAME="field" ONKEYDOWN="return validateKey(event)">
So users no more can press ctrl+t to open a new tab or ctrl+w to close
this one, or such. Angry enough yet?
The users still can rightclick and pick "paste". I can disable this by
disabling right mouse button. So they can't execute mouse gestures, they
can't pick "bookmark this page" etc. Should be angry enough by now.
Now all the users have to do is to pick Edit>Paste from the browser
menu. Or go to some less annoying page. You can't block either.