Monday, May 20, 2024
128
rated 0 times [  134] [ 6]  / answers: 1 / hits: 49445  / 10 Years ago, tue, december 2, 2014, 12:00:00
<input class=inputVal>
<script type=text/javascript>

var myVal = document.getElementsByClassName('inputVal')[0];

myVal.addEventListener('keyup', function(e){
var count = myVal.value;
console.log(count)
});
</script>

More From » addeventlistener

 Answers
17

Try bind event to document or window. If an element is not focusable and is not focused, keyboard events won't dispatch to it, instead they dispatch to document root(<body>).


[#68627] Saturday, November 29, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
abagail

Total Points: 528
Total Questions: 109
Total Answers: 101

Location: Western Sahara
Member since Mon, May 3, 2021
3 Years ago
;