The keypress event is fired when a key is pressed down and that key normally produces a character value Use keydown instead of keypress. The below example shows different events that get triggered when a key is pressed in their respective order. JavaScript Event Created: January-31, 2022 This tutorial demonstrates the different ways of using the JavaScript enter key event to stop the form submission every time the Enter key is pressed. With the keyup event, we can write the same code. , ,