For your questions 1 and 3, these are client-side events that PHP,being a process that runs on the server, cannot detect as such.
You could write a javascript that submits a form each time a visitor makes a "click" (but what do you call a click ? a clicking on a button, a link, anywhere on the page ?)
but that would be very annoying.
You could count clicks in a javascript global variable and send it in one shot, but its value would be lost if the visitors moves to another page, unless you manage to store it through some dynamic url rewriting method. Would also involve a good deal of Javascript/DHTML.
For question 3, you can use session time out, but I confess I don't know if session is destroyed as soon as the visitor closes the page, or on a time out because he's no longer active.
The point is, the server is only informed of client-side events if the client notifies it in some way or another, generally through form submission or URL rewriting.