I have a <button>
(not type="submit
) and an <input type="text"/>
on the same page.
They are not inside a form and the button is many levels above the input hierarchically.
The text input listens for keyup
events and performs a custom action that has nothing to do with what the button does.
However, on IE10, when the Enter key is pressed, the button is triggered and the text input never gets the key. Chrome, Firefox and Opera (latest all 3) are fine.
I made the button turn red when its :active
state is triggered. When you focus on the input, the button doesn't change, however after pressing Enter, it turns red.
Setting tabindex="-1"
on the button doesn't change anything.
The workarounds I found are:
- Listen for
keydown
on input andpreventDefault()
. Seemskeyup
is too late. - Place the input in a form container
I dislike both, especially the second. Is there anything else I can do?
Hoping this is something someone came up against.
EDIT: Here's a working example: http://plnkr.co/edit/LhmTpk5TpWDjOJUD18Bm?p=preview
Thank you.