JSFiddle - React, Tailwind, and code Playground
JavaScript
window.onload = function() {
inactivityTime();
};
document.onmousedown = function() {
inactivityTime();
};
document.onkeypress = function() {
inactivityTime();
};
document.ontouchstart = function() {
inactivityTime();
};
var inactivityTime = function() {
var t;
window.onload = resetTimer;
document.onmousemove = resetTimer;
document.onkeypress = resetTimer;
function logout() {
alert("You are now logged out.")
//location.href = 'logout.php'
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(logout, 3000)
// 1000 milisec = 1 sec
}
};