Keydown event cancellation demo

This page demonstrates browser functionality when a listener for the 'keydown' event immediately cancels the event it receives.

How to use:

  1. Choose one of the listener registration types. This will also display some example code.
  2. Click on the input field and try to type.

Both addEventListener and onkeydown should prevent you from being able to add or remove characters by typing. You should still be able to cut and paste text using a context menu.


Event listener: