From 346adff07d85b2c155c969e468ffb62cbe84ecbe Mon Sep 17 00:00:00 2001 From: Rita Nkem Daniel Date: Mon, 16 Oct 2023 14:11:46 +0100 Subject: [PATCH] feat: add keyboard binding for posting a highlight (#1894) --- .../molecules/HighlightInput/highlight-input-form.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/molecules/HighlightInput/highlight-input-form.tsx b/components/molecules/HighlightInput/highlight-input-form.tsx index 772457a7d3..8ce75e0692 100644 --- a/components/molecules/HighlightInput/highlight-input-form.tsx +++ b/components/molecules/HighlightInput/highlight-input-form.tsx @@ -385,7 +385,9 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E }; // Handle submit highlights - const handlePostHighlight = async (e: React.FormEvent) => { + const handlePostHighlight = async ( + e: React.FormEvent | React.KeyboardEvent + ) => { e.preventDefault(); const highlight = bodyText; @@ -520,6 +522,11 @@ const HighlightInputForm = ({ refreshCallback }: HighlightInputFormProps): JSX.E }`} defaultRow={4} value={bodyText} + onKeyUp={(e) => { + if (e.ctrlKey && e.key === "Enter") { + handlePostHighlight(e); + } + }} placeholder={`Tell us about your highlight and add a link `} typewrite={isTyping}