File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,22 @@ export function useTerminal(props: TerminalProps) {
121121
122122 term . open ( terminalRef . current ) ;
123123
124+ // https://github.com/xtermjs/xterm.js/issues/2478
125+ // my.code();ではCtrl+Cでのkeyboardinterruptは要らないので、コピーペーストに置き換えてしまう
126+ term . attachCustomKeyEventHandler ( ( arg ) => {
127+ if ( arg . ctrlKey && ( arg . key === "c" || arg . key === "x" ) && arg . type === "keydown" ) {
128+ const selection = term . getSelection ( ) ;
129+ if ( selection ) {
130+ navigator . clipboard . writeText ( selection ) ;
131+ return false ;
132+ }
133+ }
134+ if ( arg . ctrlKey && arg . key === "v" && arg . type === "keydown" ) {
135+ return false ;
136+ }
137+ return true ;
138+ } ) ;
139+
124140 setTermReady ( true ) ;
125141 onReadyRef . current ?.( ) ;
126142 }
You can’t perform that action at this time.
0 commit comments