Chapter 14. Binding on keyboard shortcuts

 

This chapter covers

  • Learning how NW.js and Electron work with keyboard shortcuts
  • Adding keyboard shortcuts to a 2D game
  • Adding global hotkey shortcuts

Power users of applications (and users of Vim) will tell you that learning keyboard shortcuts is invaluable for using apps in a fast and productive manner. For other apps, like arcade games, they can also be an essential interface method.

Programmatically binding keyboard shortcuts to your desktop app in Electron and NW.js offers your users faster ways to perform common tasks, takes some of UI scanning out of the user experience, and makes your apps easier and more pleasant to use. In this chapter, we’ll explore how to add keyboard shortcuts to a video game known as Snake.

Years ago, I built the Snake game as a Christmas/New Year project at a Ruby on Rails consultancy called New Bamboo (now part of Thoughtbot) and wrote up a tutorial about it on their site. Step forward to now, and what better example than to re-create the same game as a desktop app.

14.1. Creating the Snake game with NW.js

14.2. Creating global shortcuts for the Snake game with Electron

14.3. Summary