Issues

Issue #323 invalid

love.keypressed returns empty string on second capslock key

josefnpat
created an issue

In the following example, the capslock key was pushed four times.

{{{

!bash

seppi@seppi:~$ uname -a Linux seppi 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:17:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux }}}

{{{

!lua

function love.draw() love.graphics.print(line1, 10, 16) love.graphics.print(line2, 10, 32) love.graphics.print(line3, 10, 48) end line1 = "key: " line2 = "unicode: " line3 = "string.char: " function love.keypressed(key,unicode) line1 = line1 .. " " .. key line2 = line2 .. " " .. unicode line3 = line3 .. " " .. string.char(unicode) end }}}

The output can bee seen in the screenshot.

it seems that love.keypressed picks up the capslock button, but only when the system does not have capslock enabled.

Comments (4)

  1. josefnpat reporter

    Sorry, as a higher level user of love, I just assumed that capslock was a key like any other, and was not considering the hardware. If anyone else runs into this issue;

    The first press of capslock's goes to love.keypressed, and the second press of capslock goes to love.keyreleased.

    When I coded in C/C++/Java etc, i never used the key events, I just pretty much pulled from the STDIN, so I've never experienced this before, but it makes sense.

    Bart, thank you for bringing this to my attention, but a little more information than what you gave me will help future developers.

  2. Anonymous

    Hold up, could someone else verify that this code behaves a little oddly when one of the modifier keys is pressed? Why is that?

    function love.load()
    	pk = "press key: "
    	pu = "press unicode: "
    	ps = "press string.char: "
    	rk = "release key: "
    end
    function love.draw()
    	love.graphics.print(pk .. "\n" .. pu .. "\n" .. ps .. "\n" .. rk, 16, 16)
    end
    function love.keypressed(key,unicode)
    	pk = pk .. " " .. key
    	pu = pu .. " " .. unicode
    	ps = ps .. " " .. string.char(unicode)
    end
    function love.keyreleased(key)
    	rk = rk .. " " .. key
    end
    
  3. Log in to comment