Skip to content

Commit

Permalink
Merge pull request #24 from creasty/creasty/escape
Browse files Browse the repository at this point in the history
Pass through Ctrl-C
  • Loading branch information
creasty authored Sep 27, 2020
2 parents 0587cd7 + 413e8af commit 6ac1666
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Change the input source to English as you leave 'insert mode' in Vim with <kbd>E

| Key | Description |
|:---|:---|
| <kbd>Ctrl-C</kbd> | Invokes <kbd>EISUU, Escape</kbd> |
| <kbd>Ctrl-C</kbd> | Invokes <kbd>EISUU, Ctrl-C</kbd> |
| <kbd>Escape</kbd> | Invokes <kbd>EISUU, Escape</kbd> |

### Switch between apps
Expand All @@ -167,5 +167,5 @@ Prevents <kbd>Cmd-Q</kbd> from quiting applications.

| Key | Description |
|:---|:---|
| <kbd>Cmd-Q</kbd> | Noop |
| <kbd>Cmd-Q</kbd> | No-op |
| <kbd>Cmd-Q, Cmd-Q</kbd> | Invokes </kbd>Cmd-Q</kbd>. Quits application |
12 changes: 11 additions & 1 deletion keyboard/Handlers/EscapeHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class EscapeHandler: Handler {
guard keyEvent.isDown else {
return nil
}
guard keyEvent.match(code: .escape) else {
guard isEscapeKey(keyEvent: keyEvent) else {
return nil
}

Expand All @@ -24,4 +24,14 @@ final class EscapeHandler: Handler {
func handleSuperKey(prefix: KeyCode, keys: Set<KeyCode>) -> Bool {
return false
}

private func isEscapeKey(keyEvent: KeyEvent) -> Bool {
if keyEvent.match(code: .escape) {
return true
}
if keyEvent.match(code: .c, shift: false, control: true, option: false, command: false) {
return true
}
return false
}
}

0 comments on commit 6ac1666

Please sign in to comment.