You can use the events named Keyboard Events that are these :
The Event keydown is sent to an element when the user presses a key on the keyboard. If the key is held down, the event is sent whenever the operating system repeats the key.
KEYDOWN EVENT JQUERY
The keypress Event is sent to an element when the browser registers the keyboard input.
KEYPRESS EVENT JQUERY
The keyup Event is sent to an element when the user releases a key on the keyboard.
KEYUP EVENT JQUERY
Below you can see an example using jQuery and the above mentioned events.
You can change the event to keypress or keydown
$(function(){
$('#teste').on('keyup',function(){
console.log(this.value);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="teste">
And what is the
input
? When the functionteclaPressionada
is executed?– Woss
Are you sure you’re calling the function
teclaPressionada
?– 13dev
I entered my input field
– abduzeedo
exchange id=-"search field" for id="search field"
– Otto
@abduzeedo he is recognizing the "-" as the name of the field
– Otto
Guys, sorry about this silly mistake.
– abduzeedo