Javascript capturing user activity

前端 未结 2 850
栀梦
栀梦 2021-02-11 10:00

Is there an existing js lib for capturing user activity browser side?

ie. Scrolling, mouse moving, mouse clicking etc. I\'ve been googling, searching stackoverflow and g

2条回答
  •  萌比男神i
    2021-02-11 10:34

    You must write it yourself ( or at least that's what i did ).

    Backup question : Is there any javascript library to capture mouse/keyboards events and send them to external server?

    Here is a working jsfiddle: http://jsfiddle.net/94dd343y/

            $(document).ready(function(){
            $('html').mousemove(function(event){
                console.log("mouse move X:"+event.pageX+" Y:"+event.pageY);
            });
    
            $('html').click(function(event){
                console.log("mouse click X:"+event.pageX+" Y:"+event.pageY);
            });
    
            $('html').keyup(function(event){
                console.log("keyboard event: key pressed "+event.keyCode);
            });
        });
    

    And so on.

    If you want to capture all the events, here is a list:

    • abort
    • afterprint
    • beforeprint etc. Is it possible to programmatically catch all events on the page in the browser?

提交回复
热议问题