From 0d92f65f7e905792f2a3a662a9374523ff77e866 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 1 Jan 2023 19:41:42 +0800 Subject: [PATCH] Esc for compose field --- src/components/compose.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index e2c408ba..05fda4bd 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -2,6 +2,7 @@ import './compose.css'; import '@github/text-expander-element'; import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import stringLength from 'string-length'; import supportedLanguages from '../data/status-supported-languages'; @@ -445,6 +446,18 @@ function Compose({ setCharCount(getCharCount()); }; + useHotkeys( + 'esc', + () => { + if (!standalone && confirmClose()) { + onClose(); + } + }, + { + enableOnFormTags: true, + }, + ); + return (