Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i have diabled the ctrl key, except....

Status
Not open for further replies.

zippynz

Programmer
May 17, 2001
50
NZ
hi I have "assembled" this script to disable the use of the ctrl key, however it doesnt only disable the ctrl key,
it disables all keys!

it is run by having onKeyDown in the body tag of the doc,
it only needs to run in IE and it is just so people can't open a new window,

Code:
function disableCtrl(e) {
    if (document.all) {
        e = window.event;
    }
    var key;
    if (document.layers)
        key = e.which;
    if (document.all)
        key = e.keyCode
		window.event.returnValue = false;
}

any ideas?
 
hi zippynz.
in ur code u have disabled all the keys and hence the result........i think if you change the code if keycode==17 (which is the key value for ctrl key) that key alone should be disabled........that would solve ur problem i suppose


and btw friend, not all users press ctrl+n for new window is it....how will u prevent them from going to file and select new -> window??? u r goin to present a window w/o any of the menus is it??

Regards,
R.Subramanian
 
yes,
this is for inside a popup window,
i have also disabled right click,
and only ie users can get to this page,
it should all be good :)

so is this how i do it?
Code:
    if (document.all)
         e.keyCode == 17;
		window.event.returnValue = false;
 
hi,
no no zippynz...

try this if(document.all)
if(e.keycode==17)
window.event.returnValue=false
this should work i suppose...anyway i will test it and give u the confirmed one later...
 
Any idea how to fire a paste command on a web page? I am trying to have code write a value into a INPUT TYPE=FILE field. The .value property of file inputs does not work. I need to use code to write the value in the file input box so that I can upload it to my server. Users can click the Browse button and it will enter a value for me, but I can't figure out how to specify a value for the file input box using code. I can give the file input the focus and hit Ctrl+V or manually type in the address and it works fine. Any ideas?? I need to find a way to generate key events with javascript or a way to paste directly from the clipboard to the file input box.

Any help would be greatly appreciated.

joek@geo-comm.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top