module KeyWatcher
	include Processing::Proxy

	@@keys_down = {}

	def self.down? key
		@@keys_down[key]
	end

	def self.up? key
		!@@keys_down[key]
	end

	def self.keys_down
		@@keys_down
	end

	def self.key_pressed
		@@keys_down[$app.key_code] = true if $app.key == CODED
		@@keys_down[$app.key] = true unless $app.key == CODED
	end

	def self.key_released
		@@keys_down.delete $app.key_code if $app.key == CODED
		@@keys_down.delete $app.key unless $app.key == CODED
	end
end
