0

(Hello, I have to detect if the user is in front of his computer with my PHP/Javascript website. I am using mouse and keyboard events but they are only working if the website has the focus. I would like to detect mouse and keyboard events even if the user is on an other program.

How can I proceed ?

Dridriun
  • 21
  • 6
  • You cannot see what the user is doing on a website. Perhaps with a browser addon, but not with a webpage – mplungjan May 28 '14 at 08:39
  • I think you can't. There was a breach on Internet explorer that allowed you to record keyboard event even if the user was on an other tab. But it was a breach. – Su4p May 28 '14 at 08:39

2 Answers2

2

I don't think you can, not without writing a plug-in or similar (and getting the user to install it). Purely with client-side HTML, CSS, and JavaScript? No, I don't think you can reliably monitor anything at all when the browser isn't focussed. And I suspect it would have to be a full-on plug-in (as in NSAPI plug-in), I doubt a Firefox add-on or Chrome extension could do it.

This is, of course, a good thing. :-) Websites monitoring users when the user isn't using the website? No, thank you! :-)

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • Just to get a second opinion in: T.J's right: It's not possible without having the user install something on their system that explicitly monitors / sends this data to your website. – Cerbrus May 28 '14 at 08:42
  • Thanks for your explanation. I understand, I will find another way. – Dridriun May 28 '14 at 11:36
0

Similar question has been asked here pay attention to this answer about Page Visibility API.

Hope it helps

Community
  • 1
  • 1
Marcel Djaman
  • 1,276
  • 1
  • 17
  • 34