ar08 commited on
Commit
fd6bc47
·
verified ·
1 Parent(s): 20e35db

Update pyxtermjs/index.html

Browse files
Files changed (1) hide show
  1. pyxtermjs/index.html +27 -22
pyxtermjs/index.html CHANGED
@@ -154,30 +154,35 @@
154
  * Handle copy and paste events
155
  */
156
  function customKeyEventHandler(e) {
157
- if (e.type !== "keydown") {
158
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
160
- if (e.ctrlKey && e.shiftKey) {
161
- const key = e.key.toLowerCase();
162
- if (key === "v") {
163
- // ctrl+shift+v: paste whatever is in the clipboard
164
- navigator.clipboard.readText().then((toPaste) => {
165
- socket.emit("pty-input", { input: toPaste });
166
- });
167
- return false;
168
- } else if (key === "c" || key === "x") {
169
- // ctrl+shift+x: copy whatever is highlighted to clipboard
170
- const toCopy = term.getSelection();
171
- if (toCopy) {
172
- navigator.clipboard.writeText(toCopy).then(() => {
173
- term.focus();
174
- });
175
- }
176
- return false;
177
- }
178
- }
179
- return true;
180
  }
 
 
 
 
181
 
182
  const wait_ms = 50;
183
  window.onresize = debounce(fitToscreen, wait_ms);
 
154
  * Handle copy and paste events
155
  */
156
  function customKeyEventHandler(e) {
157
+ if (e.type !== "keydown") {
158
+ return true;
159
+ }
160
+ if (e.ctrlKey && e.shiftKey) {
161
+ const key = e.key.toLowerCase();
162
+ if (key === "v") {
163
+ // ctrl+shift+v: paste whatever is in the clipboard
164
+ navigator.clipboard.readText().then((toPaste) => {
165
+ socket.emit("pty-input", { input: toPaste });
166
+ });
167
+
168
+ // Prevent default paste action
169
+ e.preventDefault();
170
+
171
+ return false;
172
+ } else if (key === "c" || key === "x") {
173
+ // ctrl+shift+x: copy whatever is highlighted to clipboard
174
+ const toCopy = term.getSelection();
175
+ if (toCopy) {
176
+ navigator.clipboard.writeText(toCopy).then(() => {
177
+ term.focus();
178
+ });
179
  }
180
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
+ }
183
+ return true;
184
+ }
185
+
186
 
187
  const wait_ms = 50;
188
  window.onresize = debounce(fitToscreen, wait_ms);