javascript - check and uncheck the control without using the mouse,as when we hit enter key the button control gets triggered -


currently have html design wherein there textbox , button..after typing id on pressing enter page redirect,but @ same time there checkbox control.

my question :

is there option check , uncheck control without using mouse,as when hit enter key button control gets triggered

for more idea ,i have given signin window of gmail contains textbox , checkbox

enter image description here

hitting enter key trigger submit button of form currenlty focused in to. pressing tab transfer focus 1 field enter key trigger submit button of form.

but can trap keypress when hitting enter , perform check/uncheck instead of default trigger.

$("form").keypress(function (e) {     if(e.keycode === 13) {         e.preventdefault();         // code check/uncheck checkbox     } }) 

Comments