Code has been added to clipboard!

Learn to Use jQuery .keypress() to Track Keyboard Actions

Reading time 1 min
Published Jul 3, 2019
Updated Sep 30, 2019

jQuery keypress: Main Tips

  • The method .keypress() attaches an event handler for when a key is pressed, or triggers the keypress event.
  • The keypress event is similar to the keydown. However, keypress is not invoked by non-printing keys.

Usage of. keypress()

The jQuery .keypress() applies an event handler for the keypress event. It can trigger the event as well. The keypress event occurs when a key on the keyboard is pressed.

In the example below, the number of times you press keyboard keys while typing into an input field is displayed:

To simply trigger the keypress event, use this syntax:


Follow this syntax to specify a function to be executed when the event is triggered:


Warning: the actual results from jQuery .keypress() method might depend on different platforms, browsers, and their versions.

Latest Coupon Found:



Learn the skills of tomorrow

The best time to learn programming is now - follow this link to access 100+ coding courses and enjoy learning at a very low cost!

Expiration date: 13/05/2021
2287 People Used
Only 92 Left