Text Input Example

require 'gosu'

class KeyboardExample < Gosu::Window
	def initialize
		super 640, 480
		self.caption = "Keyboard Example"
		@font = Gosu::Font.new(32, name: "Nimbus Mono L")
		self.text_input = Gosu::TextInput.new
		self.text_input.text = "Type something!"
	end

	def draw
		@font.draw(self.text_input.text, 20, 40, 0)
	end
end 

window = KeyboardExample.new.show

TextInput is a Gosu class which listens for text input and captures it in its text property. This snippet takes that property and displays it so that it mimics a basic text console.