Skip to content

Commit f39fd73

Browse files
Merge pull request #49 from bernhardoj/fix/overlapped-escape-shortcut
Fix: escape shortcut key overriding each other
2 parents 7c3a1b0 + fce1ac3 commit f39fd73

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

example/src/App.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export default function App() {
4141
return KeyCommand.addListener(KEY_COMMAND, () => handleSearchCommandPress('[CMD + F] pressed'));
4242
}, []);
4343

44+
React.useEffect(() => {
45+
const KEY_COMMAND = {input: KeyCommand.constants.keyInputEscape, modifierFlags: KeyCommand.constants.keyModifierShift};
46+
return KeyCommand.addListener(KEY_COMMAND, () => handleSearchCommandPress('[Shift + Esc] pressed'));
47+
}, []);
48+
4449
React.useEffect(() => {
4550
const KEY_COMMAND = {input: KeyCommand.constants.keyInputEscape};
4651
return KeyCommand.addListener(KEY_COMMAND, () => handleSearchCommandPress('[Esc] pressed'));
@@ -78,9 +83,10 @@ export default function App() {
7883
<Text style={styles.title}>1. [CMD + F]</Text>
7984
<Text style={styles.title}>2. [G]</Text>
8085
<Text style={styles.title}>3. [Esc]</Text>
81-
<Text style={styles.title}>4. [CMD + SHIFT + K]</Text>
82-
<Text style={styles.title}>5. [ENTER]</Text>
83-
<Text style={styles.title}>6. [DOWN / UP ARROW]</Text>
86+
<Text style={styles.title}>4. [Shift + Esc]</Text>
87+
<Text style={styles.title}>5. [CMD + SHIFT + K]</Text>
88+
<Text style={styles.title}>6. [ENTER]</Text>
89+
<Text style={styles.title}>7. [DOWN / UP ARROW]</Text>
8490
</View>
8591

8692
<ScrollView style={styles.scroll}>

src/KeyCommand/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function getRegisteredCommandIndex(json) {
116116
const strictIndex = _.findIndex(commands, item => (
117117
(item.input === json.input && matchesModifierFlags(item))
118118
|| (matchesEnter(item) && matchesModifierFlags(item))
119+
|| (matchesEscape(item) && matchesModifierFlags(item))
119120
));
120121

121122
if (strictIndex < 0) {

0 commit comments

Comments
 (0)