1interface CommentSubmitShortcutEvent {
2 readonly key: string;
3 readonly metaKey: boolean;
4 readonly ctrlKey: boolean;
5}
6
7export function isCommentSubmitShortcut(
8 event: CommentSubmitShortcutEvent,
9 value: string,
10 pending: boolean,
11 allowEmpty = false,
12): boolean {
13 return (
14 !pending &&
15 (event.metaKey || event.ctrlKey) &&
16 event.key === "Enter" &&
17 (allowEmpty || value.trim().length > 0)
18 );
19}