Keyboard "up", "down", "left", "right" keys problem?

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
philipdnichols
Prole
Posts: 4
Joined: Wed Aug 03, 2011 4:48 am
Location: Boston, MA

Keyboard "up", "down", "left", "right" keys problem?

Post by philipdnichols »

It looks like only 2 of these keys can be detected to be pressed, released or down at a time. Does anyone know if this is a known issue? It looks like any other number of keyboard keys can be held down and handled correctly.

For example, if I have a character moving onscreen with the following code in love.update(timeInSeconds):

Code: Select all

self._velocity.y = 0
if love.keyboard.isDown("up") then
	self._velocity.y = self._velocity.y - 1
end
if love.keyboard.isDown("down") then
	self._velocity.y = self._velocity.y + 1
end
	
self._velocity.x = 0
if love.keyboard.isDown("left") then
	self._velocity.x = self._velocity.x - 1
end
if love.keyboard.isDown("right") then
	self._velocity.x = self._velocity.x + 1
end
If I hold down left and right, my character freezes, as expected. However, if I hold down left, up and the right, I would expect the character to only move up, but the additional press of the right key does not get detected.

Thanks for any help!
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Keyboard "up", "down", "left", "right" keys problem?

Post by Taehl »

This isn't an issue for me. I suspect that this is something your keyboard does on a hardware or driver level, as different keyboards have different ways and limits of locking multi-key input.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
XQYZ
Prole
Posts: 20
Joined: Sat Jul 30, 2011 4:23 pm
Location: Europe
Contact:

Re: Keyboard "up", "down", "left", "right" keys problem?

Post by XQYZ »

Depending on your keyboard it might be a hardware issue since there's a limit to the simultaneous key presses of keys that are wired together on the same lanes.
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Keyboard "up", "down", "left", "right" keys problem?

Post by Tesselode »

What XQYZ said. It's pretty common.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Keyboard "up", "down", "left", "right" keys problem?

Post by T-Bone »

My old PC did this too. Very annoying. Hardware issue, can't really be helped.
philipdnichols
Prole
Posts: 4
Joined: Wed Aug 03, 2011 4:48 am
Location: Boston, MA

Re: Keyboard "up", "down", "left", "right" keys problem?

Post by philipdnichols »

Ahhh I see. This makes sense.

Thanks for the replies guys!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests