Spacebar doesn't work sometimes in Safari
Quite often, while I use Safari to enter texts, the spacebar doesn't work (no response when the spacebar is pressed, but a blue rectangle shows up randomly). But it works with other apps like Notes, or Text. For not any particular reason, it works again after a while. Need some help to identify what is wrong in my computer or operation.
Current system:
Mac mini M1 2020, Monterey 12.3.1
Apple bluetooth keyboard (first generation) and mouse (2nd generation)
Thanks.