CSS & JavaScript…
It would be useful if there were some way with CSS and/or JavaScript to determine whether a focus event/state was triggered by mouse click, or keyboard.
I often have an issue where I’ll click a button to submit a form, JS validation fails and prevents the form from submitting. But we’re left with the input button in :focus-ed state.
So we’re left with either of the following situations…
I remove the focus state, and we no longer get one. Keyboard users suffer, whether that’s someone who’s unable to use a mouse, or simply just tabbing through the form for ease.
Or, I leave the focus state, and get stuck with it when validation fails or I tragically trigger .blur() on the button to get rid.
Thoughts? Solutions I’m unaware of (probably)?
Suggested solution perhaps…
input:focus-keyboard, input:focus-pointer?