Skip to content

Commit

Permalink
fix: some shortcuts causes the input to be overwritten (#581)
Browse files Browse the repository at this point in the history
* fix: open selected by shortcut

* docs: update shortcuts documentation
  • Loading branch information
dubisdev authored Aug 30, 2022
1 parent 5190403 commit 229f044
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ After installation use default shortcut `ctrl+space` to show an app window. You
* Calculator;
* Smart converter. `15$`, `150 рублей в евро`, `100 eur in gbp`;

## Shortcuts

Cerebro provides several shortcuts to improve your productivity:

* `ctrl+c`: copy the result from a plugin to the clipboard, if the plugin does not provida a result, the term you introduced will be copied
* `ctrl+1...9`: select directly a result from the list
* `ctrl+[hjkl]`: navigate through the results using vim-like keys (Also `ctrl+o` to select the result)

### Install and manage custom plugins

Use built-in `plugins` command to search and manage custom plugins.
Expand Down
5 changes: 3 additions & 2 deletions app/main/components/Cerebro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class Cerebro extends Component {
}
}

if (event.metaKey || event.ctrlKey) {
// shortcuts for ctrl+...
if ((event.metaKey || event.ctrlKey) && !event.altKey) {
if (event.keyCode === 67) {
// Copy to clipboard on cmd+c
const text = this.highlightedResult()?.clipboard || this.props.term
Expand All @@ -198,7 +199,7 @@ class Cerebro extends Component {
const number = Math.abs(49 - event.keyCode)
const result = this.props.results[number]
if (result) {
return this.selectItem(result)
return this.selectItem(result, event)
}
}

Expand Down

0 comments on commit 229f044

Please sign in to comment.