Sviside,
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
window.addEventListener('load', function() {
const limit = 5000;
let data = Array.from(document.querySelectorAll('button'), (button, i) =>
(button.addEventListener('click', () => data[i] = performance.now()), performance.now())
)
const loop = now => {
const delta = now - Math.min(...data);
if(delta > limit) show(delta);
else show(0);
requestAnimationFrame(loop)
};
const show = num => out.innerHTML = num ? `Не было нажатий ${Math.trunc(num/1000)} сек.` : '';
requestAnimationFrame(loop);
})
</script>
</head>
<body>
<button type="button">click</button>
<button type="button">click</button>
<output id="out"></output>
</body>
</html>