File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,24 @@ export class AbilityControl {
2929 inventoryIsInfinite = false ;
3030 enabled : AbilityEnableOptions ;
3131 focused : Coords | undefined ;
32- constructor ( _cx : Context , options ?: AbilityInit ) {
32+ constructor ( cx : Context , options ?: AbilityInit ) {
3333 this . enabled = options ?. enabled ?? {
3434 copy : true ,
3535 paste : true ,
3636 cut : true ,
3737 } ;
38+ document . addEventListener ( "copy" , ( e ) => {
39+ e . preventDefault ( ) ;
40+ if ( this . enabled . copy ) this . copy ( cx ) ;
41+ } ) ;
42+ document . addEventListener ( "cut" , ( e ) => {
43+ e . preventDefault ( ) ;
44+ if ( this . enabled . cut ) this . cut ( cx ) ;
45+ } ) ;
46+ document . addEventListener ( "paste" , ( e ) => {
47+ e . preventDefault ( ) ;
48+ if ( this . enabled . paste ) this . paste ( cx ) ;
49+ } ) ;
3850 }
3951 highlightCoord ( playerAt : Coords , facing : Facing ) {
4052 let dx : number ;
Original file line number Diff line number Diff line change @@ -82,10 +82,7 @@ export class Player {
8282 highlight . y = highlightCoords . y * cx . blockSize ;
8383 return highlight ;
8484 }
85- handleInput ( cx : Context , event : KeyboardEvent , eventIsKeyDown : boolean ) {
86- if ( eventIsKeyDown ) {
87- this . ability . handleKeyDown ( cx , event , this . onGround ) ;
88- }
85+ handleInput ( _cx : Context , event : KeyboardEvent , eventIsKeyDown : boolean ) {
8986 switch ( event . key ) {
9087 case "Control" :
9188 this . holdingKeys [ Inputs . Ctrl ] = eventIsKeyDown ;
You can’t perform that action at this time.
0 commit comments