garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

GM:PlayerBindPress is not called for key releases

Open robotboy655 opened this issue 11 years ago • 7 comments

This makes its third argument worthless.

hook.Add( "PlayerBindPress", "", function( ply, cmd, pressed )
    print( ply, cmd, pressed )
end )

Output:

Player [1][Rubat]   +forward    true
Player [1][Rubat]   +use    true
Player [1][Rubat]   +speed  true
Player [1][Rubat]   +use    true
Player [1][Rubat]   +speed  true
Player [1][Rubat]   +forward    true
Player [1][Rubat]   +jump   true
Player [1][Rubat]   +moveright  true
Player [1][Rubat]   +forward    true
Player [1][Rubat]   +use    true

It should at least be called for -use, -speed, etc.

robotboy655 avatar Jun 04 '14 17:06 robotboy655

Yeah it would be better to just call the -command equivalent on release, instead.

Kefta avatar Nov 02 '17 09:11 Kefta

It seems to work correctly from my tests at the moment, maybe close this ticket and remove the corresponding "BUG" from that page

Tripperful avatar Jan 22 '19 11:01 Tripperful

It definitely doesn't work correctly.

robotboy655 avatar Jan 22 '19 13:01 robotboy655

Oh, yeah, it doesn't. I just got lucky to get it working somehow with +use in my particular case, the "pressed" argument works correctly there but nowhere else. That's very strange and still needs fixing, my bad

Tripperful avatar Jan 22 '19 13:01 Tripperful

It doesnt work only on a few ones.

mcNuggets1 avatar Jun 29 '20 17:06 mcNuggets1

When this will be fixed??

lechu2375 avatar Oct 18 '20 20:10 lechu2375

I have looked into this and it's due to how engine handles the key-up events.

Basically it will only send the key-up event to the "event listener" that 'filtered' the key-down event, since it wouldn't make sense for the engine to receive the key-up event if the UI captured the key-down event. This means that the pressed argument will only ever be false and the hook itself will only ever be called for key releases if the hook itself blocked the key-press in the first place.

robotboy655 avatar Feb 04 '21 17:02 robotboy655