export default class Mouse { constructor() { this.isPressedLeft = false; this.isPressedRight = false; this.isPressedMiddle = false; this.x = 0; this.y = 0; this.addListenerMouseUp(); this.addListenerMouseDown(); this.addListenerMouseMove() } addListenerMouseUp() { window.addEventListener( 'mouseup', (event) => { console.log(this); switch (event.button) { case 0: this.isPressedLeft = false; break; case 1: this.isPressedMiddle = false; break; case 2: this.isPressedRight = false; } } ); } addListenerMouseMove() { window.addEventListener( 'mousemove', (event) => { this.x = event.clientX; this.y = event.clientY; } ); } addListenerMouseDown() { window.addEventListener( 'mousedown', (event) => { switch (event.button) { case 0: this.isPressedLeft = true; console.log(this); break; case 1: this.isPressedMiddle = true; break; case 2: this.isPressedRight = true; } } ); } }