ar08 commited on
Commit
9509aed
·
verified ·
1 Parent(s): f27baa2

Update pyxtermjs/index.html

Browse files
Files changed (1) hide show
  1. pyxtermjs/index.html +22 -22
pyxtermjs/index.html CHANGED
@@ -154,31 +154,31 @@
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
- term.write(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
+ 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>