Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom keydown handler to be attached #186

Merged
merged 6 commits into from
Jul 22, 2016

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Jul 15, 2016

Fixes #118


Example usage:

// Don't handle any events
this.xterm.attachCustomKeydownHandler(function (ev) {
  return false;
});

// Handle everything except ctrl+m
this.xterm.attachCustomKeydownHandler(function (ev) {
  return !(ev.ctrlKey && ev.keyCode === 77);
});

@Tyriar Tyriar mentioned this pull request Jul 17, 2016
* Handle a keydown event
* Key Resources:
* - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
* @param {KeyboardEvent} ev The keydown event to be handled.
*/
Terminal.prototype.keyDown = function(ev) {
if (this.customKeydownHandler && !this.customKeydownHandler(ev)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change !this.customKeydownHandler(ev) with (this.customKeydownHandler(ev) === false) in order to require users to explicitly return false to stop further handling of keys?

@parisk
Copy link
Contributor

parisk commented Jul 22, 2016

@Tyriar could you rebase with master please? I think we can move on with merging this afterwards.

@Tyriar
Copy link
Member Author

Tyriar commented Jul 22, 2016

Looking into test failure

@Tyriar Tyriar merged commit 65b2be7 into xtermjs:master Jul 22, 2016
@Tyriar Tyriar deleted the 118_support_custom_keydown_handler branch July 22, 2016 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants