I would like to detect whether the user has pressed Enter using jQuery.
How is this possible? Does it require a plugin?
EDIT: It looks like I need
event.key
$(document).keypress(function(event) { if (event.key === "Enter") { // Do something } });
or without jQuery:
document.addEventListener("keypress", function onEvent(event) { if (event.key === "Enter") { // Do something better } });
Mozilla Docs
Supported Browsers