@@ -829,6 +829,8 @@ import {ChangeTempo, ChangeReverb, ChangeVolume, ChangePan, ChangeFilterCutoff,
829829 }
830830
831831 private _tempoStepperCaptureNumberKeys = ( event : KeyboardEvent ) : void => {
832+ // When the number input is in focus, allow some keyboard events to
833+ // edit the input without accidentally editing the song otherwise.
832834 switch ( event . keyCode ) {
833835 case 8 : // backspace/delete
834836 case 13 : // enter/return
@@ -860,7 +862,6 @@ import {ChangeTempo, ChangeReverb, ChangeVolume, ChangePan, ChangeFilterCutoff,
860862 return ;
861863 }
862864
863- this . _trackEditor . onKeyPressed ( event ) ;
864865 switch ( event . keyCode ) {
865866 case 32 : // space
866867 this . _togglePlay ( ) ;
@@ -961,6 +962,91 @@ import {ChangeTempo, ChangeReverb, ChangeVolume, ChangePan, ChangeFilterCutoff,
961962 this . _doc . selection . transpose ( true , event . shiftKey ) ;
962963 event . preventDefault ( ) ;
963964 break ;
965+ case 38 : // up
966+ if ( event . shiftKey ) {
967+ this . _doc . selection . boxSelectionY1 = Math . max ( 0 , this . _doc . selection . boxSelectionY1 - 1 ) ;
968+ this . _doc . selection . selectionUpdated ( ) ;
969+ } else {
970+ this . _doc . selection . setChannelBar ( ( this . _doc . channel - 1 + this . _doc . song . getChannelCount ( ) ) % this . _doc . song . getChannelCount ( ) , this . _doc . bar ) ;
971+ this . _doc . selection . resetBoxSelection ( ) ;
972+ }
973+ event . preventDefault ( ) ;
974+ break ;
975+ case 40 : // down
976+ if ( event . shiftKey ) {
977+ this . _doc . selection . boxSelectionY1 = Math . min ( this . _doc . song . getChannelCount ( ) - 1 , this . _doc . selection . boxSelectionY1 + 1 ) ;
978+ this . _doc . selection . selectionUpdated ( ) ;
979+ } else {
980+ this . _doc . selection . setChannelBar ( ( this . _doc . channel + 1 ) % this . _doc . song . getChannelCount ( ) , this . _doc . bar ) ;
981+ this . _doc . selection . resetBoxSelection ( ) ;
982+ }
983+ event . preventDefault ( ) ;
984+ break ;
985+ case 37 : // left
986+ if ( event . shiftKey ) {
987+ this . _doc . selection . boxSelectionX1 = Math . max ( 0 , this . _doc . selection . boxSelectionX1 - 1 ) ;
988+ this . _doc . selection . scrollToSelection ( ) ;
989+ this . _doc . selection . selectionUpdated ( ) ;
990+ } else {
991+ this . _doc . selection . setChannelBar ( this . _doc . channel , ( this . _doc . bar + this . _doc . song . barCount - 1 ) % this . _doc . song . barCount ) ;
992+ this . _doc . selection . resetBoxSelection ( ) ;
993+ }
994+ event . preventDefault ( ) ;
995+ break ;
996+ case 39 : // right
997+ if ( event . shiftKey ) {
998+ this . _doc . selection . boxSelectionX1 = Math . min ( this . _doc . song . barCount - 1 , this . _doc . selection . boxSelectionX1 + 1 ) ;
999+ this . _doc . selection . scrollToSelection ( ) ;
1000+ this . _doc . selection . selectionUpdated ( ) ;
1001+ } else {
1002+ this . _doc . selection . setChannelBar ( this . _doc . channel , ( this . _doc . bar + 1 ) % this . _doc . song . barCount ) ;
1003+ this . _doc . selection . resetBoxSelection ( ) ;
1004+ }
1005+ event . preventDefault ( ) ;
1006+ break ;
1007+ case 48 : // 0
1008+ this . _doc . selection . nextDigit ( "0" ) ;
1009+ event . preventDefault ( ) ;
1010+ break ;
1011+ case 49 : // 1
1012+ this . _doc . selection . nextDigit ( "1" ) ;
1013+ event . preventDefault ( ) ;
1014+ break ;
1015+ case 50 : // 2
1016+ this . _doc . selection . nextDigit ( "2" ) ;
1017+ event . preventDefault ( ) ;
1018+ break ;
1019+ case 51 : // 3
1020+ this . _doc . selection . nextDigit ( "3" ) ;
1021+ event . preventDefault ( ) ;
1022+ break ;
1023+ case 52 : // 4
1024+ this . _doc . selection . nextDigit ( "4" ) ;
1025+ event . preventDefault ( ) ;
1026+ break ;
1027+ case 53 : // 5
1028+ this . _doc . selection . nextDigit ( "5" ) ;
1029+ event . preventDefault ( ) ;
1030+ break ;
1031+ case 54 : // 6
1032+ this . _doc . selection . nextDigit ( "6" ) ;
1033+ event . preventDefault ( ) ;
1034+ break ;
1035+ case 55 : // 7
1036+ this . _doc . selection . nextDigit ( "7" ) ;
1037+ event . preventDefault ( ) ;
1038+ break ;
1039+ case 56 : // 8
1040+ this . _doc . selection . nextDigit ( "8" ) ;
1041+ event . preventDefault ( ) ;
1042+ break ;
1043+ case 57 : // 9
1044+ this . _doc . selection . nextDigit ( "9" ) ;
1045+ event . preventDefault ( ) ;
1046+ break ;
1047+ default :
1048+ this . _doc . selection . digits = "" ;
1049+ break ;
9641050 }
9651051 }
9661052
0 commit comments