Laya 实操三:鼠标事件响应+键盘事件响应

鼠标事件响应

    onMouseDown(e){
        console.log("按下");
    }
    onMouseMove(e){
        console.log("移动");
    }
    onMouseOut(e){
        console.log("移出");
    }
    onMouseOver(e){
        console.log("进入");
    }
    onMouseUp(e){
        console.log("抬起");
    }
    onClick(e)
    {
        //e.stopPropagation();//阻止事件冒泡/上报
        console.log("点击" + this.owner.name);
    }
    onStageMouseDown(e){
        console.log("舞台中按下");
    }
    onStageMouseUp(e){
        console.log("舞台中抬起");
    }
    onStageMouseMove(e){
        console.log("舞台中移动");
    }
    onStageClick(e){
        console.log("舞台中点击");
    }

键盘事件响应

    onKeyDown(e){
        console.log(e.keyCode + "按下");//识别键值
        console.log(e.charCode + "按住");//识别字符值
    }
    onKeyUp(e){
        console.log(e.keyCode + "抬起");
    }
    onKeyPress(e){
        console.log(e.keyCode + "按住");
    }

 

你可能感兴趣的:(laya)