Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
hii all, I want to check the keypress using javascript. but I want to check it once only. Even if I hold the key it will be registered as one keypress, not continuous keypresses. I want to increase a variable if a key is pressed but it will add so many value if I hold the key what i want to achieve is if a key is pressed down even if holding down add increase the variable by one only. Anyone knows how to do this either by using scripting or with the behavior when key is pressed. |
||||
|
Still need an answer for this anybody? |
||||
|
Technic is same. https://www.ambiera.com/forum.php?t=8713 |
||||
|
I misread the question.. in javascript i do it like this.. /* If you want to use this script then you need keycode.. ENTER key is 13 so you can use it if key pressed 13 then call action.. and it will be called only once per click. |
||||
|
Thanks a lot sven, but for my case I don't want to check it with key up event, as I am also doing something when key left up. |
||||
|
You can use my script to check both..key up or down once.. |
||||
|
You are not getting me, as your script uses key left up and key down. I have one event which throws an object only once when a key is down and when the key is left up the object moves back to the hand. But right now, with any script, it only throws the object, and even when holding down it makes the object move back instantly. but I want it to move back only when I really leave the key. I don want it to trigger the action when holding down. if the key is held down perform nothing. |
||||
|
I will edit script later and post it.. So you get key up and down action to execute only one time per klick..if thats what you need. |
||||
|
This script will: Call action ONLY ONE TIME if key pressed down... (no matter if key is held down) AND if relased it calls action ONLY ONE TIME. (no matter if key left up forever) If i still misunderstood your question then i hope somebody can answer it for you. /* |
||||
|
this is exactly, what I wanted. Thanks, @sven you are a genius. this works perfectly. |
||||
|
Thanks for these tips! |
|