File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
packages/terminal/src/browser Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,9 @@ export abstract class TerminalWidget extends BaseWidget {
8080 /** Event that fires when the terminal size changed */
8181 abstract onSizeChanged : Event < { cols : number ; rows : number ; } > ;
8282
83+ /** Event that fires when the terminal receives a key event. */
84+ abstract onKey : Event < { key : string , domEvent : KeyboardEvent } > ;
85+
8386 /** Event that fires when the terminal input data */
8487 abstract onData : Event < string > ;
8588
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
9191 protected readonly onDataEmitter = new Emitter < string > ( ) ;
9292 readonly onData : Event < string > = this . onDataEmitter . event ;
9393
94+ protected readonly onKeyEmitter = new Emitter < { key : string , domEvent : KeyboardEvent } > ( ) ;
95+ readonly onKey : Event < { key : string , domEvent : KeyboardEvent } > = this . onKeyEmitter . event ;
96+
9497 protected readonly toDisposeOnConnect = new DisposableCollection ( ) ;
9598
9699 @postConstruct ( )
@@ -213,6 +216,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
213216 this . toDispose . push ( this . onDidOpenFailureEmitter ) ;
214217 this . toDispose . push ( this . onSizeChangedEmitter ) ;
215218 this . toDispose . push ( this . onDataEmitter ) ;
219+ this . toDispose . push ( this . onKeyEmitter ) ;
216220
217221 const touchEndListener = ( event : TouchEvent ) => {
218222 if ( this . node . contains ( event . target as Node ) ) {
@@ -242,6 +246,10 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
242246 this . onDataEmitter . fire ( data ) ;
243247 } ) ) ;
244248
249+ this . toDispose . push ( this . term . onKey ( data => {
250+ this . onKeyEmitter . fire ( data ) ;
251+ } ) ) ;
252+
245253 for ( const contribution of this . terminalContributionProvider . getContributions ( ) ) {
246254 contribution . onCreate ( this ) ;
247255 }
You can’t perform that action at this time.
0 commit comments