Logout for inactivity

Hi, I’m using Keycloak version 18.0.
I would like to implement a flow where the user needs to login with username and password.
Then when the user is logged in, if he is inactive for a configurable time, the user needs to re-authenticate himself with for example a PIN.
Instead if the user logs out, to login he needs to authenticate with username and password.

I’ve already tried to implement something like this, but I can’t find a way to tell keycloak that the user is being logged out by the session timeout.
Do you know if there is a way to do anything like this without modifying the code? Or is it only possible to do it with some code implementation?

Thank you