473,322 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Question about keyboard key detection, need help

Happy 2007 all... :-)

I am looking for a way in JavaScript in IE 7.0 only, to have it detect
the Backspace key on the keyboard.

So like,

<script>

if backSpaceKeyPressed {

do stuff....

}

</script>

I can't seem to get this to work. Can someone please help me?

AnGie%

Jan 22 '07 #1
2 1784
al*****@gmail.com wrote:
I am looking for a way in JavaScript in IE 7.0 only, to have it detect
the Backspace key on the keyboard.
So like,
<script>
if backSpaceKeyPressed {
do stuff....
}
</script>

I can't seem to get this to work. Can someone please help me?
msdn.microsoft.com/workshop/author/dhtml/reference/events/onkeypress.asp
msdn.microsoft.com/workshop/author/dhtml/reference/objects/body.asp

<body onkeypress="if (event.keyCode==8) { alert('you pressed
backspace'); return false; }" onload="self.focus()">

Three remarks:

- focus needs to be in browser page (that's why I added the
onLoad-event)
- 'return false' is to prevent 'Go to previous page' (history back)
- MSIE proprietary

Hope this helps,

--
Bart

Jan 22 '07 #2
"Bart Van der Donck" <ba**@nijlen.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
al*****@gmail.com wrote:
>I am looking for a way in JavaScript in IE 7.0 only, to have it detect
the Backspace key on the keyboard.
So like,
<script>
if backSpaceKeyPressed {
do stuff....
}
</script>

I can't seem to get this to work. Can someone please help me?

msdn.microsoft.com/workshop/author/dhtml/reference/events/onkeypress.asp
msdn.microsoft.com/workshop/author/dhtml/reference/objects/body.asp

<body onkeypress="if (event.keyCode==8) { alert('you pressed
backspace'); return false; }" onload="self.focus()">

Three remarks:

- focus needs to be in browser page (that's why I added the
onLoad-event)
- 'return false' is to prevent 'Go to previous page' (history back)
- MSIE proprietary
No it is not. However, only onkeydown and onkeyup is reliable as the keyCode is always
set in those events.

-Lost
Feb 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
9
by: Marek Mand | last post by:
How to use generated keyboard events? What I am trying here to do is in onkeyup event handler http://www.hot.ee/idaliiga/braggart/createEventTest.htm generate a (shift)TAB keydown so the...
1
by: Tim Conkling | last post by:
I've run into a problem with a game I'm designing -- I (think) I need to do something ugly, for speed reasons, and I'm wondering if people here might have any ideas about how solve my problem more...
1
by: Darren Coleman | last post by:
I need help with 2 keyboard/input questions 1. How do i caputre all keypress events for my application/form? 2. How do I determine which keyboard sent the keypress? What i'm doing is using a...
14
by: Gidi | last post by:
Hi, For the last week, i'm looking for a way to make a TextBox always write in English (No matter what the OS default language is). i asked here few times but the answers i got didn't help me. i...
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
1
by: darkjemz | last post by:
whats wrong with this?? plz help me!!ASAP... #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <dos.h>
0
by: darrenhello | last post by:
hi there, I am doing my last year's project and I have a 'little' problem. I have to do an edge detection filter. for now, some normal edge detection filters that I used worked fine but there a...
0
by: origami.takarana | last post by:
Intrusion Detection Strategies ----------------------------------- Until now, we’ve primarily discussed monitoring in how it relates to intrusion detection, but there’s more to an overall...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.