User interaction for presence detection?

Does someone know how to use a keylogger[0] or dbus[1] for presence detection?

[0] https://github.com/kernc/logkeys
[1] https://unix.stackexchange.com/a/290073/274797