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 ?

2
  • You cannot see what the user is doing on a website. Perhaps with a browser addon, but not with a webpage
    – mplungjan
    May 28, 2014 at 8: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, 2014 at 8:39

2 Answers 2

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! :-)

2
  • 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, 2014 at 8:42
  • Thanks for your explanation. I understand, I will find another way.
    – Dridriun
    May 28, 2014 at 11:36
0

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

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.