.active {
background: black;
color: white;
}
const handler = e =>
(e.type === 'click' || e.buttons === 1) &&
e.target.classList.contains('but') &&
e.target.classList.add('active');
document.addEventListener('click', handler);
document.addEventListener('mousemove', handler);