@@ -31,6 +31,7 @@ function Term(options)
3131 {
3232 }
3333
34+ this . options = options
3435 width = options . cols ? options . cols : 80 ;
3536 height = options . rows ? options . rows : 25 ;
3637 scrollback = options . scrollback ? options . scrollback : 0 ;
@@ -101,6 +102,9 @@ function Term(options)
101102 this . linux_console = true ;
102103
103104 this . textarea_has_focus = false ;
105+
106+ // remember last data (to help WebXRKeyboard decide whether onblur should imply 'enter')
107+ this . last = { keydown : '' , input : '' , inputValue : '' }
104108}
105109
106110Term . prototype . setKeyHandler = function ( handler )
@@ -1154,6 +1158,7 @@ Term.prototype.keyDownHandler = function (ev)
11541158 }
11551159 break ;
11561160 }
1161+ this . last . keydown = str
11571162 // console.log("keydown: keycode=" + ev.keyCode + " charcode=" + ev.charCode + " str=" + str + " ctrl=" + ev.ctrlKey + " alt=" + ev.altKey + " meta=" + ev.metaKey);
11581163 if ( str ) {
11591164 if ( ev . stopPropagation )
@@ -1204,7 +1209,13 @@ Term.prototype.to_utf8 = function(s)
12041209Term . prototype . inputHandler = function ( ev )
12051210{
12061211 var str ;
1207- str = this . textarea_el . value ;
1212+ // edge-case: Meta's WebXRKeyboard implementation requires us to use .value
1213+ str = this . last . input = this . textarea_el . value . split ( "" ) . pop ( ) ;
1214+ // edge-case: detect backspace based on length-change [Meta's WebXRKeyboard]
1215+ if ( ( this . textarea_el . value . length + 1 ) == this . last . inputValue . length ) {
1216+ str = '\b'
1217+ }
1218+ this . last . inputValue = this . textarea_el . value
12081219 if ( str ) {
12091220 this . textarea_el . value = "" ;
12101221 this . show_cursor ( ) ;
@@ -1243,6 +1254,7 @@ Term.prototype.blurHandler = function (ev)
12431254 /* allow unloading the page */
12441255 window . onbeforeunload = null ;
12451256 this . textarea_has_focus = false ;
1257+ if ( this . last . keydown != "\n" && this . last . input && this . options . isWebXRKeyboard ( ) ) this . handler ( "\n" )
12461258} ;
12471259
12481260Term . prototype . pasteHandler = function ( ev )
0 commit comments