Skip to content

web_netcat: implement copy with Ctrl + Shift + C #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions web_netcat/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
letterSpacing: 0,
fontFamily: 'monospace',
});
term.attachCustomKeyEventHandler((e) => {
// Ctrl + Shift + C, to prevent browser from opening devtools
if (e.ctrlKey && e.shiftKey && e.keyCode == 67) {
e.preventDefault();
const success = document.execCommand('copy');
if (!success) {
console.error('Failed to copy to clipboard');
}
}
});
const fitAddon = new FitAddon.FitAddon();
term.loadAddon(fitAddon);
term.open(document.getElementById("terminal"));
Expand Down