Inactivity detection

I need to detect if an user is inactive (browser open but no interaction) to release blocked items after a while. I need this in multiple locations. Is there any way to get notified globally when the user clicked a mouse button or pressed a key? Or are there any other ideas how to implements inactivity detection?

My personal preference is to register a heartbeat listener for the UI. In there you can access the LastRequestTimestamp which is updated when the user does something which would hit the server like clicking buttons, adding text to a field or changing views.

@quirky-zebra Heartbeat doesn’t does the trick because it’s also triggered automatically

It does the trick because the last request time is not increased from it, therefore it can be used to calculate the difference from last to now

I expected it to be increased but it still doesn’t do the trick because it per Session and I need it on a per UI basis :frowning_with_open_mouth:

@yummy-rhino When I understand the addon correctly it registers a listener to all xhr requests? Maybe it would be possible to adapt the code.

@quirky-zebra I checked were the lastRequestTimestamp in the VaadinSession is set and maybe it’s an option to override the findUi method in the VaadinService.It looks like it’s called whenever a new request arrives