Assign the "onclick" event to the window object: window.onclick = myFunction; … The submit event is sent to an element when the user is attempting to submit a form. Click on a button to copy some text from an input field to another input field: Try it Yourself » Example. Both actions lead to submit event on the form. Submit button automatically submits a form on click. Here we are calling a validate() function before submitting a form data to the webserver. In this example, s is specified as the access key (you'll need to press s plus the particular modifier keys for your browser/OS combination. The web is a big place and all that. So