-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathglobalKeys.ts
More file actions
144 lines (136 loc) · 3.65 KB
/
globalKeys.ts
File metadata and controls
144 lines (136 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/**
* Contains mappings for special keyboard controls, beyond what is usually expected of a webpage
* Learn more about keymaps at https://github.com/greena13/react-hotkeys#defining-key-maps (12.03.2021)
*
* Additional global configuration settins are placed in "./config.ts"
* (They are not placed here, because that somehow makes the name fields of keymaps undefined for some reason)
*
* If you add a new keyMap, be sure to add it to the getAllHotkeys function
*/
import { match } from "@opencast/appkit";
import { ParseKeys } from "i18next";
import { isMacOs } from "react-device-detect";
// Groups for displaying hotkeys in the overview page
const groupVideoPlayer = "keyboardControls.groupVideoPlayer";
const groupCuttingView = "keyboardControls.groupCuttingView";
const groupCuttingViewScrubber = "keyboardControls.groupCuttingViewScrubber";
const groupSubtitleList = "keyboardControls.groupSubtitleList";
/**
* Helper function that rewrites keys based on the OS
*/
export const rewriteKeys = (key: string | IKey) => {
const newKey = typeof key === "string" ?
key : key.splitKey ?
key.key.replaceAll(key.splitKey, "+") : key.key;
return isMacOs ? newKey.replace("Alt", "Option") : newKey;
};
export const getGroupName = (groupName: string): ParseKeys => {
return match(groupName, {
videoPlayer: () => groupVideoPlayer,
cutting: () => groupCuttingView,
timeline: () => groupCuttingViewScrubber,
subtitleList: () => groupSubtitleList,
}) ?? "keyboardControls.defaultGroupName";
};
export interface IKeyMap {
[property: string]: IKeyGroup;
}
export interface IKeyGroup {
[property: string]: IKey;
}
export interface IKey {
name: string;
key: string;
splitKey?: string;
}
export const DEFAULT_KEYMAP: IKeyMap = {
videoPlayer: {
play: {
name: "keyboardControls.videoPlayButton",
key: "Shift+Alt+Space, Space",
},
previous: {
name: "video.previousButton",
key: "Shift+Alt+Left",
},
next: {
name: "video.nextButton",
key: "Shift+Alt+Right",
},
preview: {
name: "video.previewButton",
key: "Shift+Alt+p",
},
},
cutting: {
cut: {
name: "cuttingActions.cut-button",
key: "Shift+Alt+c",
},
delete: {
name: "cuttingActions.delete-button",
key: "Shift+Alt+d",
},
mergeLeft: {
name: "cuttingActions.mergeLeft-button",
key: "Shift+Alt+n",
},
mergeRight: {
name: "cuttingActions.mergeRight-button",
key: "Shift+Alt+m",
},
zoomIn: {
name: "cuttingActions.zoomIn",
key: "Shift;Alt;r, +",
splitKey: ";",
},
zoomOut: {
name: "cuttingActions.zoomOut",
key: "Shift+Alt+e, -",
},
},
timeline: {
left: {
name: "keyboardControls.scrubberLeft",
key: "Shift+Alt+j , Left",
},
right: {
name: "keyboardControls.scrubberRight",
key: "Shift+Alt+l, Right",
},
increase: {
name: "keyboardControls.scrubberIncrease",
key: "Shift+Alt+i, Up",
},
decrease: {
name: "keyboardControls.scrubberDecrease",
key: "Shift+Alt+k, Down",
},
},
subtitleList: {
addAbove: {
name: "subtitleList.addSegmentAbove",
key: "Shift+Alt+q",
},
addBelow: {
name: "subtitleList.addSegmentBelow",
key: "Shift+Alt+a",
},
jumpAbove: {
name: "subtitleList.jumpToSegmentAbove",
key: "Shift+Alt+w",
},
jumpBelow: {
name: "subtitleList.jumpToSegmentBelow",
key: "Shift+Alt+s",
},
delete: {
name: "subtitleList.deleteSegment",
key: "Shift+Alt+d",
},
addCue: {
name: "subtitleList.addCue",
key: "Shift+Alt+e",
},
},
};