Keyboard.isDown is not working with G and H key.

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
User avatar
ddabrahim
Prole
Posts: 32
Joined: Mon May 17, 2021 8:05 pm
Contact:

Keyboard.isDown is not working with G and H key.

Post by ddabrahim »

Hi.

I'm using LOVE 11.3 on macOS 11.4 and I believe I have discovered a bug, but it could also be just my keyboard.
If I would like to do something when the G and the H key both is down and I also holding the Space key, so I have 3 key down Space, G and H then nothing is happening, the code is not firing. I experience this problem only with G and H. other keys are working.

Here is a project that reproduce the problem for me.
ghbugtest.love.zip
(641 Bytes) Downloaded 152 times
This is the code:

Code: Select all

local message

function love.load(arg)
end

function love.update(dt)
  if love.keyboard.isDown('g') and love.keyboard.isDown('h') then
    message = 'G and H is down'
  else
    message = 'G and H is not down'
  end
end

function love.draw()
  love.graphics.print('Hold Space key and then press and hold G and H',0,100,0,2,2)
  love.graphics.print(message,0,200,0,2,2)
  
end
Could someone please try and confirm if it a problem with my keyboard or my system or it is an actual BUG in LOVE?

Thanks.
Last edited by ddabrahim on Mon Jul 12, 2021 4:42 pm, edited 1 time in total.
grump
Party member
Posts: 818
Joined: Sat Jul 22, 2017 7:43 pm

Re: [BUG] keyboard.isDown is not working with G and H key.

Post by grump »

That's a hardware limitation, not a software bug. Common keyboards are not capable of recognizing arbitrary key combinations due to how their key matrix works. Different keyboards allow for different simultaneous key presses, there is no common pattern to it, and you should not rely on any specific behavior. Only explicit modifier keys such as Shift, Alt, etc. can be used like that.
User avatar
darkfrei
Party member
Posts: 419
Joined: Sat Feb 08, 2020 11:09 pm

Re: [BUG] keyboard.isDown is not working with G and H key.

Post by darkfrei »

This hardware bug was much often by PS/2 keyboards.
:awesome: Falling in LÖVE :awesome:
I Löve Lua and Love2D
User avatar
darkfrei
Party member
Posts: 419
Joined: Sat Feb 08, 2020 11:09 pm

Re: [BUG] keyboard.isDown is not working with G and H key.

Post by darkfrei »

I can press QWER, ASDF, but not QAWS or QAED or QARF or WSED or EDRF

Code: Select all

function love.load()
	keypressed = {}
end

function love.draw()
	local y = 20
	for key, scancode in pairs (keypressed) do
		love.graphics.print ('key:	'..key..'	scancode:	'..scancode, 20, y)
		y=y+20
	end
end

function love.keypressed(key, scancode, isrepeat)
	keypressed[key] = scancode
end

function love.keyreleased (key, scancode)
	keypressed[key] = nil
end
Attachments
key-jamming-keyboard-01.love
(375 Bytes) Downloaded 150 times
:awesome: Falling in LÖVE :awesome:
I Löve Lua and Love2D
User avatar
slime
Solid Snayke
Posts: 2954
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: [BUG] keyboard.isDown is not working with G and H key.

Post by slime »

User avatar
ddabrahim
Prole
Posts: 32
Joined: Mon May 17, 2021 8:05 pm
Contact:

Re: [BUG] keyboard.isDown is not working with G and H key.

Post by ddabrahim »

Thank you all!. I was suspecting it could be my keyboard but I had no clue it is a common problem with keyboards. The link to the 'ghost tester', did confirm Space+G+H does not send a signal on my keyboard for the last character. I wish I knew this earlier, spent hours debugging my code on the weekend :D Happy days!
Post Reply

Who is online

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