How do you clear input control values on keyclick(enter)?


How would you clear an input value (like a text field) on enter?


Assign a variable to the document element and use .value ="" to set the value to empty
var element = document.querySelector("YOUR TEXT FIELD);
Use a keyListener to trigger the event

window.onkeydown = function(e) {
   var key = e.keyCode ? e.keyCode : e.which;

   if (key == '*enter keycode value') {
element.value = "";