How to use keypress - 10 common examples

To help you get started, we’ve selected a few keypress examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rauchg / clif / lib / index.js View on Github external
toolbar: this.toolbar,
      quality: this.quality
    });

    env = clone(env || process.env);
    env.TERM = env.TERM || 'xterm-256color';

    this.pty = pty(shell, argv, {
      cwd: cwd,
      rows: this.rows,
      columns: this.cols,
      env: env
    });

    // in
    if (this.keys) keypress(process.stdin);
    this.rawState = process.stdin.isRaw;
    process.stdin.setRawMode(true);
    process.stdin.resume();
    process.stdin.pipe(this.pty.stdin);
    process.stdin.on('keypress', (c, k) => this.key(c, k));

    // out
    this.pty.stdout.on('data', buf => this.out(buf));
    this.pty.on('exit', () => this.complete());

    // poll title
    if (this.toolbar) this.getTitle();
  }
github ghoranyi / docker-intuition-backend / vizceral / src / components / trafficFlow.jsx View on Github external
import Vizceral from 'vizceral-react';
require('vizceral-react/dist/vizceral.css');

import Breadcrumbs from './breadcrumbs';
import DisplayOptions from './displayOptions';
import FilterControls from './filterControls';
import NodeDetails from './nodeDetails';
import LoadingCover from './loadingCover';
import Locator from './locator';
import OptionsPanel from './optionsPanel';
import UpdateStatus from './updateStatus';

import filterActions from './filterActions';
import filterStore from './filterStore';

const listener = new keypress.Listener();

// Start TWEEN updates for sparklines and loading screen fading out
import TWEEN from 'tween.js';
function animate (time) {
  requestAnimationFrame(animate);
  TWEEN.update(time);
}
requestAnimationFrame(animate);

const panelWidth = 400;


class TrafficFlow extends React.Component {
  constructor (props) {
    super(props);
    this.state = {
github guo-yu / player / libs / cli.js View on Github external
var beginWith = str.charAt(0)
    if (beginWith === '~' || beginWith == '/')
      return true

    return false
  }

  var vol = 1

  function updateVolume() {
    player.setVolume(vol)
    console.log('volume: ' + Math.floor(vol * 100))
  }

  keypress(process.stdin);

  var paused = false

  process.stdin.on('keypress', function (ch, key) {
    if (key && key.ctrl && key.name == 'c') {
      process.exit(0)
    }
    if (key && key.name == 'space') {
      player.pause()
      if(!paused)
        console.log('paused')
      else
        console.log('resuming')
      paused = !paused
    }
    if (key && key.name == 'x') {
github Urucas / ScreenRec / lib / index.js View on Github external
wait4key() {
    
    if(this.options.silent == false) console.log("Press [ctrl + c] to stop recording".white);
    let key = keypress(process.stdin);
    let self = this;

    process.stdin.on('keypress', function (ch, key) {
      if (key && key.ctrl && key.name == 'c') {
        process.stdin.pause();
        self.stop();
      }
    });
  
    process.stdin.setRawMode(true);
    process.stdin.resume();
  }
github azproduction / node-mc / lib / tui-terminal / lib / tui-events.js View on Github external
_activateKeyboardEvents() {
        keypress(this._stdin);

        this._stdin.on('keypress', (character, key) => {
            this.emit('event', this._translateKeyboardEvent('keypress', character, key));
        });

        this._stdin.setRawMode(true);
        this._stdin.resume();
    }
github rizowski / eslint-watch / src / index.js View on Github external
function keyListener(args, options) {
  let stdin = process.stdin;
  if (!stdin.setRawMode) {
    logger.debug('Process might be wrapped exiting keybinding');
    return;
  }
  keypress(stdin);
  stdin.on('keypress', function keyPressListener(ch, key) {
    logger.debug('%s was pressed', key ? key.name : ch);
    if (key && key.name === 'return') {
      logger.debug('relinting...');
      logger.debug(options);
      runLint(args, options);
    }
    if (key && key.ctrl && key.name === 'c') {
      process.exit();
    }
  });
  stdin.setRawMode(true);
  stdin.resume();
}
github JonathanUsername / nplaym / src / io.js View on Github external
});

  npm.on('close', d => {
    gameOver(true);
  });

  process.on('exit', function () {
    npm.kill('SIGINT');
    term.showCursor();
  });

  process.stdin.setRawMode(true);

  term.hideCursor();

  keypress(process.stdin);

  process.stdin.on('keypress', function (chunk, key) {
    if (!key) return; 
    if (key.ctrl && key.name == 'c') {
      process.exit(1);
    }
    switch (key.name) {
      case 'left':
        term.right(1);
        player.left = Math.max(player.left - 1, LEFTWALL);
      break;
      case 'right':
        term.left(1);
        player.left = Math.min(player.left + 1, WIDTH - RIGHTWALL);
      break;
      case 'space':
github icyflame / cli-cube-timer / index.js View on Github external
process.stdin.on('mousepress', function (click) {
    if (click.release) {
      space_or_mouse();
    }
  });

  process.on('exit', function () {
    //disable mouse on exit, so that the state is back to normal for the terminal.
    keypress.disableMouse(charm);
  });

  process.stdin.resume();

  charm.reset();
  keypress.enableMouse(charm);
  botSay("Hey! Let's start solving!");
  botSay('The session starts now!');

  start_inspect = print_help(right_row_num, 1);

  charm.position(1, start_inspect)
  start_inspect += prepNewSolve();

  start_time = (new Date()).toTimeString().split(' ')[0]

  var total_time = new Stopwatch();
  total_time.start();
  charm.position(1, start_inspect);
};
github kjirou / escape-from-the-maze / input / AppInput.es6 View on Github external
import keypress from 'keypress';
import Rx from 'rx';

import {onError} from 'input/subscriptions/error';
import {onKeypress} from 'input/subscriptions/keypress';
import {onTimer} from 'input/subscriptions/timer';
import SingletonMixin from 'lib/mixins/SingletonMixin';
import {calculateMillisecondsPerFrame} from 'lib/util';

keypress(process.stdin);
process.stdin.setRawMode(true);
process.stdin.resume();


export default class AppInput {

  constructor() {
    let pauser = new Rx.Subject();

    let timerSource = Rx.Observable
      .timer(0, calculateMillisecondsPerFrame())
      .timeInterval()
      .map((data) => {
        pauser.onNext(true);
        return data;
      })
github mjhd-devlion / promviz-front / src / components / trafficFlow.jsx View on Github external
import LoadingCover from './loadingCover';
import Locator from './locator';
import OptionsPanel from './optionsPanel';
import CustomVizceral from './customVizceral';
import ReplayClock from './replayClock';
import ServerStatus from './serverStatus';

import filterActions from './filterActions';
import filterStore from './filterStore';

import trafficActions from './trafficActions';
import trafficStore from './trafficStore';

import AppConstants from '../appConstants';

const listener = new keypress.Listener();

const hasOwnPropFunc = Object.prototype.hasOwnProperty;

function animate (time) {
  requestAnimationFrame(animate);
  TWEEN.update(time);
}
requestAnimationFrame(animate);

const panelWidth = 400;

class TrafficFlow extends React.Component {
  static defaultProps = {
    interval: 10 * 1000,
    maxReplayOffset: 12 * 60 * 60
  }

keypress

Make any Node ReadableStream emit "keypress" events

MIT
Latest version published 11 years ago

Package Health Score

65 / 100
Full package analysis