I have an input on an HTML page where a person will enter something, and what I want is a function that needs to be called every time they stop typing. I know about the onkeypress event, but this is called every time a character is typed. Here is an example of what I would like:
Is it possible?
Thank you so much!
onkeyupevent. - ( "" , ), - .
onkeydown, .
- ...
var timer; function onKeyUpHandler(e){ timer = setTimeout("foo()", 500) } function onKeyDownHandler(e) { clearTimeout(timer); }
, , ... .
javascript / onKeyPress. , " " script.
"key up" "stopTyping" true. ( , " " ).
, , "", "stopTyping = false"
, "stopTyping". , (, ). , - , , char .
If I understand well, "stop typing" means "no keystrokes for a certain amount of time." In this case you need to use timers: http://jsfiddle.net/xnghR/1/