@@ -827,7 +827,7 @@ function createSqueakDisplay(canvas, options) {
827
827
deadChars = deadChars . concat ( chars ) ;
828
828
}
829
829
}
830
- if ( ! deadChars . length ) input . value = "" ; // clear input
830
+ if ( ! deadChars . length ) resetInput ( ) ;
831
831
} ;
832
832
input . onkeydown = function ( evt ) {
833
833
checkFullscreen ( ) ;
@@ -890,6 +890,32 @@ function createSqueakDisplay(canvas, options) {
890
890
if ( ! display . vm ) return true ;
891
891
recordModifiers ( evt , display ) ;
892
892
} ;
893
+ function resetInput ( ) {
894
+ input . value = "**" ;
895
+ input . selectionStart = 1 ;
896
+ input . selectionEnd = 1 ;
897
+ }
898
+ resetInput ( ) ;
899
+ // hack to generate arrow keys when moving the cursor (e.g. via spacebar on iPhone)
900
+ // we're not getting any events for that but the cursor (selection) changes
901
+ if ( 'ontouchstart' in document ) {
902
+ let count = 0 ; // count how often the interval has run after the first move
903
+ setInterval ( ( ) => {
904
+ const direction = input . selectionStart - 1 ;
905
+ if ( direction === 0 ) {
906
+ count = 0 ;
907
+ return ;
908
+ }
909
+ // move cursor once, then not for 500ms, then every 250ms
910
+ if ( count === 0 || count > 2 ) {
911
+ const key = direction < 1 ? 28 : 29 ; // arrow left or right
912
+ recordKeyboardEvent ( key , Date . now ( ) , display ) ;
913
+ }
914
+ input . selectionStart = 1 ;
915
+ input . selectionEnd = 1 ;
916
+ count ++ ;
917
+ } , 250 ) ;
918
+ }
893
919
// more copy/paste
894
920
if ( navigator . clipboard ) {
895
921
// new-style copy/paste (all modern browsers)
0 commit comments