From 03a12413d632a2a1613091e44c52ce46b4adc5b8 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Fri, 19 Apr 2024 09:02:56 +0530 Subject: Minor refactoring to move repeated code into utility class --- src/features/webControls/components/WebControls.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/features/webControls/components') diff --git a/src/features/webControls/components/WebControls.tsx b/src/features/webControls/components/WebControls.tsx index aee568a7d..25b23cbee 100644 --- a/src/features/webControls/components/WebControls.tsx +++ b/src/features/webControls/components/WebControls.tsx @@ -15,6 +15,7 @@ import { import withStyles, { type WithStylesProps } from 'react-jss'; import { Tooltip as ReactTooltip } from 'react-tooltip'; import Icon from '../../../components/ui/icon'; +import { isEnterKeyPress, isEscapeKeyPress } from '../../../jsUtils'; const messages = defineMessages({ goHome: { @@ -215,7 +216,7 @@ class WebControls extends Component { }); }} onKeyDown={event => { - if (event.key === 'Enter') { + if (isEnterKeyPress(event.key)) { this.setState({ editUrl: false, }); @@ -224,7 +225,7 @@ class WebControls extends Component { if (this.inputRef?.current) { this.inputRef.current.blur(); } - } else if (event.key === 'Escape') { + } else if (isEscapeKeyPress(event.key)) { this.setState({ editUrl: false, inputUrl: url, -- cgit v1.2.3-70-g09d2