Jump to content

Strange IsControlPressed Behaviour


Recommended Posts

For some things I've set up generic key handlers that I can easily adjust for whatever I'm doing, but I've come across a problem that I can't figure out at all. I'm not sure if it's a bug or something to do with how IsControlPressed works. My problem can be replicated with the following: 

TheInput:AddKeyHandler(function(key, down) 
    if not down and key == string.byte("m") then 
        if TheInput:IsControlPressed(CONTROL_FORCE_STACK) then 
            print("Successful") 
        else 
            print("Unsuccessful") 
        end 
    end 
end) 

I'm not sure if it's OS specific, game specific, or what it is, but when I trigger this it prints Unsuccessful almost always, and when it does print Successful, I have no idea what's different from other times.

If I change strint.byte("m") to string.byte("n") then it will print Successful, but the problem isn't in the string.byte check because something will always print when either key is used for the check. The problem's in the IsControlPressed check, but I have no idea why specific keys cause this strange behaviour.

If anyone knows, could you please explain what's happening with IsControlPressed, and specifically what causes this problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...