I have a simple code...
document.addEventListener('keydown', function (e)
{
if (e.keyCode == 13 || e.keyCode == 32)
{
e.preventDefault();
$(e.target).trigger("click");
}
});
this is working fine with keycode 32 (space), but not for keycode 13 (enter) where it always submits the form. I tried adding prevent default after reading answers to some similar questions, but it doesnt solve the issue. the form is submitted anyways after pressing enter.I am looking after a solution which can be written in the script tag; since I do not want to disturb the form tags. Also, this script(without the prevent default) was working fine till some days ago.