How to determine if a checkbox was checked using the mouse or keyboard?

I know this is a strange question, but is it possible to determine (using PHP / JavaScrip) the source of the "validation" device? I need to find out when the user clicks on the checkbox which device he used for the actual click.

Hope I have a point here.

+4
source share
1 answer

With Javascript, this is easy. You can attach click and keydown events to the checkbox ( onclick , onkeydown or use jQuery if you want) and they will fire when you press or when you press a key. By "click" from the keyboard, I assume that you mean highlighting the checkbox through tabs and pressing the spacebar. This will still raise the keydown event, but not the click.

+2
source

Source: https://habr.com/ru/post/1399301/


All Articles