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% 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)
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
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)
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.
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?
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) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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( ...
|
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...
|
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...
|
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...
|
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...
|
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);"...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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
|
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...
| |