Is it possible to clear the value field by clicking on enter?

Is it possible to clear the value field by clicking on enter ?
<input class="form-control search-control" type="text" value="aayat" placeholder="Search..." name="search">
July 9th 19 at 13:03
3 answers
July 9th 19 at 13:05
Solution
$("#target").on("keypress", function( event ) { // or keyup, keydown
 if (event.which === 13) {
$(this).val("");
}
});
July 9th 19 at 13:07
Solution
<input onkeydown="if(event.keyCode==13) this.value="" value="123">
July 9th 19 at 13:09

Find more questions by tags JavaScript