Can't get shift+key symbols to work.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
naughty
Prole
Posts: 8
Joined: Mon Apr 09, 2012 2:30 pm

Can't get shift+key symbols to work.

Post 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?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post 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.
naughty
Prole
Posts: 8
Joined: Mon Apr 09, 2012 2:30 pm

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

Post by naughty »

I totally missed the unicode argument to love.keypressed(). Thanks for that!
Post Reply

Who is online

Users browsing this forum: No registered users and 89 guests