Jos,
You should be able to use lastkey() fairly reliably in this scheme.
>This does not test for keyboard activity but how likely is it that the user never touches the mouse in 30 minutes in your app? You could also test for keyboard activity if you feel you need to.