Page 1 of 1

Can't get shift+key symbols to work.

Posted: Thu Feb 28, 2013 11:51 am
by naughty
Looking in the wiki it seems that '!' is a valid key. But on my UK keyboard you write it with shift+1 but it comes through to love.keypressed() as 1. Also love.keyboard.isDown('!') won't trigger.

I could make a table of shifted keys but it's not the same for all countries, e.g. quote and double quote are different between UK and US keyboards and I have no way to detect the locale of the user.

Is there a standard way to deal with this sort of thing in Love? Should I just steer clear of symbol keys?

Re: Can't get shift+key symbols to work.

Posted: Thu Feb 28, 2013 12:20 pm
by bartbes
Typically, you use the unicode argument to love.keypressed. As for why? Well, the key actually being depressed is the 1 key, the unicode character generated is the exclamation mark, there is a difference between those two things.

Re: Can't get shift+key symbols to work.

Posted: Thu Feb 28, 2013 12:55 pm
by naughty
I totally missed the unicode argument to love.keypressed(). Thanks for that!