Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Modifiers and KeyEvent — Gideros Forum

Modifiers and KeyEvent

perrochonperrochon Member
edited July 2020 in General questions
Another noob question: What I'd like to do is to distinguish between e.g. SHIFT + NUM_1 and just NUM_1.

It looks like KeyEvent don't have modifiers, but MouseEvents do. Is that correct? It would be nice if I could just check modifiers in the NUM_1 KEY_DOWN event. I looked at https://github.com/gideros/gideros/blob/master/libgid/include/ginput.h which seems to confirm this.

I think I can do it by listening to KEY_DOWN and KEY_UP on SHIFT and keeping track, but that is behaving unexpectedly.
If I press and hold SHIFT , then NUM_5 down and hold, then lift NUM_5, then lift SHIFT, I am getting a shift up before I get the shift down for the NUM_5 key.
self:addEventListener(Event.KEY_UP, function(event)
		if event.keyCode == KeyCode.SHIFT then
			self.shift = false
			DEBUG("SHIFT up")
		end
	end)
 
	self:addEventListener(Event.KEY_DOWN, function(event)
		DEBUG("Key Down", self.shift, event.keyCode, event.realCode)			
		if event.keyCode == KeyCode.SHIFT then
			self.shift = true
			DEBUG("SHIFT down")
		end
 	end)

Comments

Sign In or Register to comment.