How to implement custom events in jQuery?

Custom event means you can create your own events in jQuery. For example, create a custom event to fire an alert box on pressing any key on the keyboard.


You can try to run the following code to learn how to create a custom event,

Live Demo

<!DOCTYPE html>
<script src=""></script>
     alert("You have pressed Enter key!");
     if(e.keyCode == 13)
<textarea rows="2" cols="20">