当我处于焦点文本区域时停止播放视频



当我键入空格键时,帕利视频。但是,如果我专注于写播放视频的" textarea"。如果我专注于Textarea,我想停止视频。帮我!


window.onkeypress = function(e) {
    if (e.srcElement.className.indexOf('dragClass') > -1) { 
        if (e.keyCode === 1300) {
            divWidth = document.getElementById('controlBar').clientWidth;
            if (divWidth < canvas.width)
                scale = divWidth / canvas.width;
            else
                scale = 1;
            curSize += 0;
            ctx.font = curSize + 'px Arial';
            ctx.fillStyle = curColor;
            ctx.fillText(textBox.value, mouseX / scale, mouseY / scale); 
            videoDiv.removeChild(textBox);
        }
    } else if (e.srcElement.id == 'textArea') {;
    } else {
        if (e.keyCode === 32) { 
            $('.play-pause-btn-' + modalId).blur();
            if (vid.paused) {
                vid.play();
                playbtn.style.background = "url(/assets/images/common/btn_pause_black.png) 50% 50% no-repeat";
                loop();
            } else {
                vid.pause();
                playbtn.style.background = "url(/assets/images/common/btn_play_black.png) 50% 50% no-repeat";
            }
        }
        if (e.keyCode === 44) {
            previousframeStep();
        }
        if (e.keyCode === 46) {
            nextframeStep();
        }
    }

这是我的代码。

而不是" e.srcelement.id"使用" e.target.id"。同样,如果Textarea对象的事件侦听器触发了您想要的事情而不是窗口对象,那就更好了。如果您想通过" ID"方法检查,您也应该在其中进行安全检查,因为并非所有对象都有ID属性,并且会丢弃错误!

if (e.target.id && e.target.id === "textarea")\then do whatever

最新更新