Search code examples
rubykeylistenerarrow-keys

How to detect arrow-keys pressed in Ruby?


I'm creating a simple game in ruby and want to detect when different keys are pressed, especially the arrow-keys. I have done this in Java before, but can't seem to find how this is done in ruby.

Does anyone know whether or not ruby has a similar kind of KeyEvent and getKeyCode() as in Java?


Solution

  • From the comments, this approach seems to have worked for OP. https://gist.github.com/acook/4190379