require 'ruby2d' set title: '4' set width: 600 set height: 40 set background: 'white' x=0; on :key_down do |e| t = Text.new(x:x, text: e.key, size: 30, font: '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf', color: "random") x = x+t.width end show