Giter Site home page Giter Site logo

crtrdg-tty's Introduction

crtrdg-tty

keyboard module for games that works in the terminal

Useful for testing and debugging core game logic outside the browser, e.g. because you have separate modules for game logic and rendering and you want to test gameplay alone in the terminal. Works well alongside crtrdg.js games, but can be used just as well independently. Captures key presses from stdin using keypress and separates key down and key up events using lodash.debounce.

install

npm install --save crtrdg-tty

example

initialize and log key down events

var TTY = require('crtrdg-tty')

var tty = TTY()

tty.on('keyDown', function (key) {
	console.log(key)
})

to see a simple interactive demo call

npm start

inside this module, and press or hold keys to see events.

API

create

create the tty object

var TTY = require('crtrdg-tty')

var tty = TTY()

tty.on('keyDown')

key down events

provides a key code for the key pressed from vkey

tty.on('keyUp')

key up events

provides a key code for the key let up from vkey

tty.keysDown

object with currently pressed keys set to true, e.g.

tty.on('keyDown', function () {
  console.log(tty.keysDown)
})

>> {<up>: true}

crtrdg-tty's People

Contributors

freeman-lab avatar sethvincent avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.