0

Which keycode for escape key with jQuery

$(document).keyup(function(e) {
  if (e.keyCode === 13) $('#panel').html('Enter');     // enter
  if (e.keyCode === 27) $('#panel').html('Esc');   // esc
});
<div id="panel">
  [KEY]
</div>
#panel {
  padding: 100px;
  font-size: 40px;
  border: 5px solid #dddddd;
  text-align: center;
}
RUN
add comment
Suggest a different solution or add another example