473,325 Members | 2,308 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,325 software developers and data experts.

need if (event.keyCode expert

Hi, can someone help me put together a if (event.keyCode function, that
will detect when the # character is pressed twice, and then
dosomething() ?

Sincerely,

%Julia%

Jul 23 '05 #1
6 1751
Julia Briggs wrote on 19 mrt 2005 in comp.lang.javascript:
Hi, can someone help me put together a if (event.keyCode function, that
will detect when the # character is pressed twice, and then
dosomething() ?


<script type='text/javascript'>

var n=0

function x(){
if(event.keyCode==35){
n+=1
if (n==2)alert('2 x #')
}
}

</script>
<input onkeypress='x()'>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2
Evertjan. wrote:
Julia Briggs wrote on 19 mrt 2005 in comp.lang.javascript:

Hi, can someone help me put together a if (event.keyCode function, that
will detect when the # character is pressed twice, and then
dosomething() ?

<script type='text/javascript'>

var n=0

function x(){
if(event.keyCode==35){
n+=1
if (n==2)alert('2 x #')


if (n==2){alert('2 x #');n = 0}

better maybe?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #3
Randy Webb wrote on 19 mrt 2005 in comp.lang.javascript:
Evertjan. wrote:
Julia Briggs wrote on 19 mrt 2005 in comp.lang.javascript:

Hi, can someone help me put together a if (event.keyCode function,
that will detect when the # character is pressed twice, and then
dosomething() ?

<script type='text/javascript'>

var n=0

function x(){
if(event.keyCode==35){
n+=1
if (n==2)alert('2 x #')


if (n==2){alert('2 x #');n = 0}

better maybe?


No, I dont think so.

Why improve on a OQ we don't know the reason of.

================

Perhaps two or more consecutive #'es are ment,
but also that is not asked.

function x(){
if(event.keyCode==35) n++ else n=0
if (n>=2) alert('2 or more #\'s consecutive')
}

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #4
Lee
Randy Webb said:

Evertjan. wrote:
Julia Briggs wrote on 19 mrt 2005 in comp.lang.javascript:

Hi, can someone help me put together a if (event.keyCode function, that
will detect when the # character is pressed twice, and then
dosomething() ?

<script type='text/javascript'>

var n=0

function x(){
if(event.keyCode==35){
n+=1
if (n==2)alert('2 x #')


if (n==2){alert('2 x #');n = 0}

better maybe?


Better, but without knowing what the OP really wants to detect,
we don't know if it really does the job. If it's to prevent two
#'s from being entered in a single field, for example, it would
have to check the whole field value after each keystroke.

And of course, it would be much better to audit for that onchange.

Jul 23 '05 #5
Lee
Evertjan. said:

Randy Webb wrote on 19 mrt 2005 in comp.lang.javascript:
Evertjan. wrote:
Julia Briggs wrote on 19 mrt 2005 in comp.lang.javascript:
Hi, can someone help me put together a if (event.keyCode function,
that will detect when the # character is pressed twice, and then
dosomething() ?

<script type='text/javascript'>

var n=0

function x(){
if(event.keyCode==35){
n+=1
if (n==2)alert('2 x #')


if (n==2){alert('2 x #');n = 0}

better maybe?


No, I dont think so.

Why improve on a OQ we don't know the reason of.


Why try to guess at answers to an OQ you don't understand?

Jul 23 '05 #6
Lee wrote on 19 mrt 2005 in comp.lang.javascript:
Why improve on a OQ we don't know the reason of.


Why try to guess at answers to an OQ you don't understand?


It is quite possible to understand a Q
without understanding for what purpose that Q is asked.

Improving on such Q however is out of the Q, Lee. ;-)

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #7

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

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
3
by: Matthias Knöchlein | last post by:
hi !! I have the following problem : Is there a function or a constant value to check if a keyCode is a key kile "Shift", "Alt" or "F1". I would like not to use this way : if( ...
5
by: Alan Zhong | last post by:
i am trying to similate an "ENTER" as a key to switch focus in a sequence of text inputs. i don't want to use "event.keyCode" since i want to do additional testing before i decide which text input...
1
by: Perttu Pulkkinen | last post by:
I have different functions that receive window.event as parameter. Functions are used like this: <input type="text" id="x" onkeypress="return onKeyCurrencyCheck(ev, 'x')" onblur...
4
by: Thomas Christensen | last post by:
I'm trying to figure out what key the user pressed using a Danish keyboard layout. charCodeAt returns the correct number, but event.keyCode returns a wrong number, when using one of the keys that...
4
by: melanieab | last post by:
Hi, Sorry this is a long message, but I'm getting desperate (and worried). I have a textbox (say, tb1) where the string is longer than the width of the box. If I'm coming from the previous...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
1
by: dana1 | last post by:
I have a form with several combo boxes in the header used to determine the records that will be displayed on the form. When I tab or enter from the last combo box in the header, I want the focus to...
33
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
0
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...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.