Skip to content

Commit

Permalink
Merge pull request hainproject#150 from jminjie/ctrl-navigation
Browse files Browse the repository at this point in the history
Ctrl+N/P/J/K navigation (hainproject#146)
  • Loading branch information
appetizermonster committed Jun 1, 2016
2 parents 1313c11 + 3355bdb commit a1ad612
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions app/renderer-jsx/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,31 @@ class AppContainer extends React.Component {
Enter: this.handleEnter.bind(this),
Tab: this.handleTab.bind(this)
};
const ctrlKeyHandlers = {
P: this.handleSelection.bind(this, -1),
p: this.handleSelection.bind(this, -1),
K: this.handleSelection.bind(this, -1),
k: this.handleSelection.bind(this, -1),
N: this.handleSelection.bind(this, 1),
n: this.handleSelection.bind(this, 1),
J: this.handleSelection.bind(this, 1),
j: this.handleSelection.bind(this, 1)
};
const selectedHandlerForCtrl = ctrlKeyHandlers[key];
const selectedHandler = keyHandlers[key];
if (selectedHandler !== undefined) {
selectedHandler();
evt.preventDefault();
if (evt.ctrlKey) {
if (selectedHandlerForCtrl !== undefined) {
selectedHandlerForCtrl();
evt.preventDefault();
} else if (selectedHandler !== undefined) {
selectedHandler();
evt.preventDefault();
}
} else {
if (selectedHandler !== undefined) {
selectedHandler();
evt.preventDefault();
}
}
}

Expand Down

0 comments on commit a1ad612

Please sign in to comment.