How to Create your own Keyboard Shortcuts in HyperTerm

NOTICE: This may be obsolete. I stopped using HyperTerm again! (Too many things failed). The project has been renamed (to “Hyper”). And the special handling for danish keyboards seems to have been fixed. All in all - you may learn a bit about how to create keyboard shortcuts - but the specifics are probably unusable now.

Create a new plugin:

# create a new directory
mkdir plugin name
# Initialize a new git repository
git init plugin name
# Create it on github (assumes you have the hub command installed)
hub create
# Create a new npm package in current dir.
npm init

create index.js file with plugin code… That’s pretty much it.

Danish Keyboard

Missing tilde and backtick - because the alt key is trapped somehow. Just map them yourself. This is as easy as getting the keycodes for the keys in question, and then mapping them in a plugin so that when pressing the key combination normally used for these keys, you print them to the terminal…

Get keycode from this page on css tricks

And then, this is the code:

exports.decorateTerm = (Term, { React }) => {
  return class extends React.Component {

    constructor (props, context) {
      super(props, context);
      this._onTerminal = this._onTerminal.bind(this);
    }

    _onTerminal (term) {
      if (this.props && this.props.onTerminal) this.props.onTerminal(term);

      const handler = [
        "keydown",
        function(e) {
            // fix tilde
          if (e.altKey && e.keyCode === 221) {
            e.preventDefault();
            this.terminal.io.sendString('~');
          }
            // fix backtick
          if (e.shiftKey && e.keyCode === 187) {
            e.preventDefault();
            this.terminal.io.sendString('`');
          }
        }.bind(term.keyboard)
      ];

      term.uninstallKeyboard();
      term.keyboard.handlers_ = [handler].concat(term.keyboard.handlers_);
      term.installKeyboard();
    }

    render () {
      return React.createElement(Term, Object.assign({}, this.props, {
        onTerminal: this._onTerminal
      }));
    }

  };
};

Mostly boilerplate stuff.