term.js icon indicating copy to clipboard operation
term.js copied to clipboard

Paste (and copy) are broken on Safari

Open vincentwoo opened this issue 9 years ago • 3 comments

Trying to copy/paste in safari using cmd + c / cmd + v on latest Safari and term.js (v0.0.7) doesn't work.

copy

The keypress handler swallows cmd + c, and doesn't let the browser do its thing.

paste

Paste events are tricky in Safari - you need some kind of input element or contenteditable target for the paste event to fire. Traditional workarounds include catching a keydown for cmd + v and quickly focusing an editable element and catching paste on that.

vincentwoo avatar Sep 02 '15 01:09 vincentwoo

Upon further investigation I think the proper course of action is probably for term.js to always have a hidden input element. It seems like it already does this in a limited fashion for mobile browsers. A hidden text element will allow you to much more reliably capture paste events.

vincentwoo avatar Sep 02 '15 23:09 vincentwoo

Hello, can you test the firefox patch https://github.com/chjj/term.js/issues/51 ? it fix also for Chrome. But CTRL+C don't work also in firefox (it deselect the text) but menubar copy work.

VigibotDev avatar Oct 09 '15 18:10 VigibotDev

@vincentwoo I made a Pull-Request that enable Copy and Paste using hidden text area. https://github.com/chjj/term.js/pull/97

yoshiokatsuneo avatar Nov 09 '15 08:11 yoshiokatsuneo