Situation:
Goal:
--> How can I detect the keyboard input into the hidden input field?
I know the keydown / keypress / keyup events, however they seem to require a visible input field
You can bind the event to the document like this:-
$(document).bind('keyup', function(e) {
alert('testing');
});
You can also simply position the element off-canvas, without needing to alter its DOM/CSS visibility state.
<style> .inputValue{position:absolute;left:-99999px} </style>
<input type="text" class="inputValue" autofocus="autofocus"/>
And then at any given point when you require the input's value you call the below script.
<script> $('.inputValue').val(); </script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.