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

javascript
#1

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

#2

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 = "";
}