blob: 82bce4ae56a0e30d459e1ea0c9c2089e5265165a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
require 'ruby2d'
set width: 200, height: 100, title: "Ruby 2D — Input"
on key_down: 'a' do
puts "Key 'a' down"
end
on key: 'b' do
puts "Key 'b' held down"
end
on key_up: 'c' do
puts "Key 'c' up"
end
on key_down: 'any' do
puts "A key was pressed"
end
on_key do |key|
if key == 'd'
puts "on_key: #{key}"
end
end
on mouse: 'any' do |x, y|
puts "Mouse clicked at: #{x}, #{y}"
end
on key: 'escape' do
close
end
show
|