Home > Software design >  How to prevent input checkbox being affected by spacebar?
How to prevent input checkbox being affected by spacebar?

Time:10-07

So, I've got this input of type checkbox for a dropdown menu on the top. When I click on it and select something, for some reason clicking the spacebar toggles it on/off...clicking once elsewhere doesn't fix it either, I have to click outside twice.

I don't quite understand why I have to click twice outside, but regardless, I want to know how I can stop this from happening. I suppose I have to do something with focus...but I can't seem to understand it properly - nor do I know if that is indeed the problem.

CodePudding user response:

If you don't need the spacebar for your any button on the form, you can do an event.preventDefaut() on keypress for the spacebar.

  • Related