mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 10:53:51 +00:00
refactor: extract utility
This commit is contained in:
committed by
Carlos Valente
parent
760de608e3
commit
44f65b2fcc
@@ -7,3 +7,11 @@ export function isKeyEnter<T>(event: KeyboardEvent<T>): boolean {
|
||||
export function isKeyEscape<T>(event: KeyboardEvent<T>): boolean {
|
||||
return event.key === 'Escape';
|
||||
}
|
||||
|
||||
export function preventEscape<T>(event: KeyboardEvent<T>, callback?: () => void): void {
|
||||
if (isKeyEscape(event)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
callback?.();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user