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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is there any way to overwrite the delete key on list boxes?

Status
Not open for further replies.

debrac

IS-IT--Management
Jan 9, 2001
48
0
0
AU
is there any way to overwrite the delete key on list boxes? as when a user presses delete on a list box, it goes to the previous page.
thanks,
 
What exactly is this "list box" that you speak of, anyway?

Based on your question, though, I doubt JavaScript has the power to accomplish what you are asking for.

Oh yes... the correct word isn't "overwrite"; instead, it's "override."
 
i was talking about list menus in forms. and overriding the delete key pressed, on it.
 
In javascript, no event fires when a delete key is pressed. This means that you are not capable of cancelling it, since you can't even detect it.
 
what about with dhtml or html? for all my list menus, i want to override the delete key, so that when it is pressed, it wont go back a page. is there another way to do it?
thanks
 
Java gives you that capability...

But the languages normally contained under the category of DHTML are not given the capability of catching or cancelling delete. And pure HTML can barely do anything.

Do you happen to have any friends who know Java?
 
Hi
Yes you can capture key events with javascript. Here's the code

<script>
//Detect Browser
var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;

function ondelpress()
{
if (NS4 || N6)
{
if (evt.which==127)
{
//Do whatever you want to do when u press delete key here,I mean put your logic here
}
}
if (IE4 || IE5)
{
if (window.event.keyCode==127)
{
//Do whatever you want to do when u press delete key here,I mean put your logic here
}
}
}

Put a onKeyUp event handler to run this script whenevr u want to appropriately in your html like

onKeyUp=&quot;ondelpress()&quot;

Lemme know if you have problems.
Badrinath Chebbi
 
Hi
Yes you can capture key events with javascript. Here's the code

<script>
//Detect Browser
var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;

function ondelpress()
{
if (NS4 || N6)
{
if (evt.which==127)
{
//Do whatever you want to do when u press delete key here,I mean put your logic here
}
}
if (IE4 || IE5)
{
if (window.event.keyCode==127)
{
//Do whatever you want to do when u press delete key here,I mean put your logic here
}
}
}
</script>

Put a onKeyUp event handler to run this script whenevr u want to appropriately in your html like

onKeyUp=&quot;ondelpress()&quot;

Lemme know if you have problems.
Badrinath Chebbi
 
Oh, I see... I tested using the
Code:
onkeypress
event. It doesn't detect delete presses. Sorry for the mixup.
 
does the code above also cover IE6 ?
thanks for your help.
 
yep, it will.

if you do navigator.appVersion on IE6 it gives you version 4. so, yep i think so. The pen is mightier than the sword.
 
The nice thing about IE is that if IE 4 or 5 had it, 6 also will accept it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top