jQuery: How to use modifier keys on form submit?
Posted
by Svish
on Stack Overflow
See other posts from Stack Overflow
or by Svish
Published on 2010-06-09T15:45:07Z
Indexed on
2010/06/09
15:52 UTC
Read the original article
Hit count: 172
Say I have a form that looks like this:
[ Animal name input field ]
Add button
If I type a name and hit enter, an animal with the given name is added to a table. Works fine. What I would like now is to call the current way of working "quick add" and add a new feature called "slow add", which I am not quite sure how to do. Basically what I want is that if for example the shift key is held down when enter or the button is clicked, I want the form submit method to do something slightly different. In my case I want it to open up a form where more details on the animal can be added before it is added to the table.
Problem is I'm not quite sure how to do this. I have tried add a FireBug console.info(eventData)
in my current submit function and I have found that the eventData
contains an altKey, shiftKey and controlKey property, but they are always undefined even when I hold those keys down.
So, does anyone know how I can do something special in my submit handler when certain modifier keys were pressed when the form was submitted?
© Stack Overflow or respective owner