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

Update pyxtermjs/index.html

Browse files
Files changed (1) hide show
  1. pyxtermjs/index.html +25 -22
pyxtermjs/index.html CHANGED
@@ -154,31 +154,34 @@
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
- navigator.clipboard.writeText(toCopy);
172
- term.focus();
173
- return false;
174
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
- return true;
177
- }
178
 
179
- const wait_ms = 50;
180
- window.onresize = debounce(fitToscreen, wait_ms);
181
- term.attachCustomKeyEventHandler(customKeyEventHandler);
182
  </script>
183
  </body>
184
  </html>
 
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);
184
+ term.attachCustomKeyEventHandler(customKeyEventHandler);
185
  </script>
186
  </body>
187
  </html>