Skip to content
Permalink
Browse files

Enable keypress events when raw mode is turned on

  • Loading branch information...
vadimdemedes committed Mar 8, 2019
1 parent 321aa1e commit 675b456b74e69f7869a0fc238b35077154d8f454
Showing with 3 additions and 1 deletion.
  1. +1 −1 readme.md
  2. +2 −0 src/components/App.js
@@ -671,7 +671,7 @@ Usage:
Type: `function`<br>

See [`setRawMode`](https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode).
Ink exposes this function via own `<StdinContext>` to be able to handle <kbd>Ctrl</kbd>+<kbd>C</kbd>, that's why you should use Ink's `setRawMode` instead of `process.stdin.setRawMode`.
Ink exposes this function via own `<StdinContext>` to be able to handle <kbd>Ctrl</kbd>+<kbd>C</kbd>, that's why you should use Ink's `setRawMode` instead of `process.stdin.setRawMode`. Ink also enables `keypress` events via [`readline.emitKeypressEvents()`](https://nodejs.org/api/readline.html#readline_readline_emitkeypressevents_stream_interface) when raw mode is enabled.

Usage:

@@ -1,3 +1,4 @@
import readline from 'readline';
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import cliCursor from 'cli-cursor';
@@ -70,6 +71,7 @@ export default class App extends PureComponent {
stdin.addListener('data', this.handleInput);
stdin.resume();
stdin.setRawMode(true);
readline.emitKeypressEvents(stdin);
}

this.rawModeEnabledCount++;

0 comments on commit 675b456

Please sign in to comment.
You can’t perform that action at this time.