class InputHandler {
    constructor() {
        this.keys = {
            a: false,
            d: false,
            ArrowLeft: false,
            ArrowRight: false
        };
        
        this.init();
    }
    
    init() {
        window.addEventListener('keydown', (e) => {
            if (this.keys.hasOwnProperty(e.key)) {
                e.preventDefault();
                this.keys[e.key] = true;
            }
        });
        
        window.addEventListener('keyup', (e) => {
            if (this.keys.hasOwnProperty(e.key)) {
                e.preventDefault();
                this.keys[e.key] = false;
            }
        });
    }
    
    isMovingLeft() {
        return this.keys.a || this.keys.ArrowLeft;
    }
    
    isMovingRight() {
        return this.keys.d || this.keys.ArrowRight;
    }
}

const input = new InputHandler();
