jquery.terminal icon indicating copy to clipboard operation
jquery.terminal copied to clipboard

browser keypresses such as function buttons are cancelled when term input is paused

Open ordo-n opened this issue 10 months ago • 5 comments

Issue summary

when term.pause(true) f11 doesnt work to go fullscreen, is it just me?

Expected behavior

should not prevent All keypresses

Steps to reproduce

term.pause(true) try f11

Browser and OS

all chrome, edge on windows

ordo-n avatar Jan 16 '25 03:01 ordo-n

I can reproduce, thanks for the report

jcubic avatar Jan 16 '25 11:01 jcubic

When paused, all key shortcuts are blocked, except CTRL+D that unpause the terminal. Keys are blocked only when terminal is in focus.

You can disable this by using:

$('body').terminal({}, {
   pauseEvents: false,
   keydown() {
     return true;
   }
});

jcubic avatar Jan 16 '25 11:01 jcubic

When paused, all key shortcuts are blocked, except CTRL+D that unpause the terminal. Keys are blocked only when terminal is in focus.

You can disable this by using:

$('body').terminal({}, { pauseEvents: false, keydown() { return true; } });

I tried this code and when the terminal is Not paused some keys like enter, backspace and up and down arrow keys are none responsive

ordo-n avatar Jan 16 '25 14:01 ordo-n

You're right, didn't check the Cmd plugin, when keydown returns anything non-undefined, the rest of the code is not executed. You need to check if the terminal is paused:

$('body').terminal({}, {
     pauseEvents: false,
     keydown() {
         if (this.paused()) {
             return true;
         }
     }
});

And if you want to allow CTRL+D to unpause and cancel AJAX requests you need:

const term = $('body').terminal({}, {
    pauseEvents: false,
    keydown(e) {
        if (this.paused() && !(e.key === 'D' && e.ctrlKey)) {
            return true;
        }
    }
});

jcubic avatar Jan 16 '25 18:01 jcubic

That works perfectly. Thanks so much for your help!:)

ordo-n avatar Jan 16 '25 19:01 ordo-n