Today I was asked by a colleague to aid them with adding functionality to a form that would allow it to be submitted by pressing ‘ctr + s’ keys.
As a group of web developers this key combination is something that comes almost naturally to us when editing and constantly saving code, so should prove a useful addition to the form that is not too difficult to implement.
I began by setting up the event observers to watch for the two required keys to be pressed.
Once the required key codes ( 17 and 83 ) were captured it should have been a case of simply referencing the form and applying the submit method.
To see if what was written so far would actually perform the desired action we tested the page using our default browser Firefox, only to discover we were receiving the following error:
document.forms.form_id.submit is not a function
This was all very puzzling but eventually resorting to a search on Google provided a number of answers.