-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lib): allow shortcuts to contain alphabetic characters
- Loading branch information
Showing
6 changed files
with
121 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
projects/ngx-drag-to-select/src/lib/keyboard-events.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { share } from 'rxjs/operators'; | ||
import { fromEvent } from 'rxjs'; | ||
import { distinctKeyEvents } from './operators'; | ||
|
||
@Injectable() | ||
export class KeyboardEventsService { | ||
keydown$ = fromEvent<KeyboardEvent>(window, 'keydown').pipe(share()); | ||
keyup$ = fromEvent<KeyboardEvent>(window, 'keyup').pipe(share()); | ||
|
||
// distinctKeyEvents is used to prevent multiple key events to be fired repeatedly | ||
// on Windows when a key is being pressed | ||
|
||
distinctKeydown$ = this.keydown$.pipe( | ||
distinctKeyEvents(), | ||
share() | ||
); | ||
|
||
distinctKeyup$ = this.keyup$.pipe( | ||
distinctKeyEvents(), | ||
share() | ||
); | ||
|
||
mouseup$ = fromEvent<MouseEvent>(window, 'mouseup').pipe(share()); | ||
mousemove$ = fromEvent<MouseEvent>(window, 'mousemove').pipe(share()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters