Skip to content

🎥 Make videos programmatically with React

add A and E shortcuts

Jonny Burgerc4c44ada3326
diff --git a/packages/cli/src/editor/components/KeyboardShortcutsModal.tsx b/packages/cli/src/editor/components/KeyboardShortcutsModal.tsx
index 9b2d8eec08..4edc9d3f5c 100644
--- a/packages/cli/src/editor/components/KeyboardShortcutsModal.tsx
+++ b/packages/cli/src/editor/components/KeyboardShortcutsModal.tsx
@@ -105,6 +105,21 @@ export const KeyboardShortcuts: React.FC = () => {
</div>
<div style={right}>1 second forward</div>
</Row>
+
+ <br />
+ <br />
+ <Row align="center">
+ <div style={left}>
+ <kbd style={key}>A</kbd>
+ </div>
+ <div style={right}>Jump to beginning</div>
+ </Row>
+ <Row align="center">
+ <div style={left}>
+ <kbd style={key}>E</kbd>
+ </div>
+ <div style={right}>Jump to end</div>
+ </Row>
<br />
<br />
<Row align="center">
diff --git a/packages/cli/src/editor/components/PlayPause.tsx b/packages/cli/src/editor/components/PlayPause.tsx
index ded03fd26d..c838f7ef78 100644
--- a/packages/cli/src/editor/components/PlayPause.tsx
+++ b/packages/cli/src/editor/components/PlayPause.tsx
@@ -57,22 +57,36 @@ export const PlayPause: React.FC<{
return null;
}
- frameBack(e.shiftKey ? videoFps : 1);
e.preventDefault();
+
+ if (e.altKey) {
+ seek(0);
+ } else if (e.shiftKey) {
+ frameBack(videoFps);
+ } else {
+ frameBack(1);
+ }
},
- [frameBack, videoFps]
+ [frameBack, seek, videoFps]
);
const onArrowRight = useCallback(
(e: KeyboardEvent) => {
- if (!videoFps) {
+ if (!video) {
return null;
}
- frameForward(e.shiftKey ? videoFps : 1);
+ if (e.altKey) {
+ seek(video.durationInFrames - 1);
+ } else if (e.shiftKey) {
+ frameForward(video.fps);
+ } else {
+ frameForward(1);
+ }
+
e.preventDefault();
},
- [frameForward, videoFps]
+ [frameForward, seek, video]
);
const oneFrameBack = useCallback(() => {
@@ -87,6 +101,14 @@ export const PlayPause: React.FC<{
seek(0);
}, [seek]);
+ const jumpToEnd = useCallback(() => {
+ if (!video) {
+ return;
+ }
+
+ seek(video.durationInFrames - 1);
+ }, [seek, video]);
+
const keybindings = useKeybinding();
useEffect(() => {
@@ -101,13 +123,17 @@ export const PlayPause: React.FC<{
onArrowRight
);
const space = keybindings.registerKeybinding('keydown', ' ', onSpace);
+ const a = keybindings.registerKeybinding('keydown', 'a', jumpToStart);
+ const e = keybindings.registerKeybinding('keydown', 'e', jumpToEnd);
return () => {
arrowLeft.unregister();
arrowRight.unregister();
space.unregister();
+ a.unregister();
+ e.unregister();
};
- }, [keybindings, onArrowLeft, onArrowRight, onSpace]);
+ }, [jumpToEnd, jumpToStart, keybindings, onArrowLeft, onArrowRight, onSpace]);
if (isStill) {
return null;