Erlang Notes

prim_tty
Login

prim_tty

getch() in pure Erlang

A combination of undocumented features mentioned in issue #8037 allow you to handle keyboard events and develop simple terminal user interfaces in pure Erlang, without having to resort to something like native extensions.

The little two-puzzle Sokoban game in games/sokoban-demo handles the terminal this way.


The features:

  1. the erl -user $module invocation to have user code handle the interface, instead of eshell
  2. the prim_tty module itself

To do this is an escript, you need -user escript rather than your module. The non-demo games/sokoban demonstrates the rebar.config change needed for that.