File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -50,21 +50,33 @@ function activatePanelButtonOnCoordinates(x, y) {
5050}
5151
5252function attachMouseListeners ( ) {
53- window . addEventListener ( "click" , ( event ) => {
53+ function handleMouseClick ( event ) {
5454 activatePanelButtonOnCoordinates ( event . clientX , event . clientY ) ;
55- } ) ;
55+ }
56+
57+ window . addEventListener ( "click" , handleMouseClick ) ;
58+
59+ return function dispose ( ) {
60+ window . removeEventListener ( "click" , handleMouseClick ) ;
61+ } ;
5662}
5763
5864function attachKeyboardListeners ( state ) {
59- window . addEventListener ( "keydown" , ( event ) => {
65+ function handleKeyDown ( event ) {
6066 if ( event . key !== "Enter" ) {
6167 return ;
6268 }
6369
6470 const cursor = state . get ( ( prevState ) => prevState . cursor ) ;
6571
6672 activatePanelButtonOnCoordinates ( cursor . x , cursor . y ) ;
67- } ) ;
73+ }
74+
75+ window . addEventListener ( "keydown" , handleKeyDown ) ;
76+
77+ return function dispose ( ) {
78+ window . removeEventListener ( "keydown" , handleKeyDown ) ;
79+ } ;
6880}
6981
7082function attachGamepadListeners ( state ) {
You can’t perform that action at this time.
0 commit comments