Using Windows Function Keys Beyond F4

How would I go about utilizing the Function (F) keys beyond F4 (ShowSpare…)?

  • FP

Check these out: http://wiki.garrysmod.com/page/Enums/KEY

There are some enums that are KEY_F1 - KEY_F12. I haven’t confirmed myself that they work though.

As long the input hook (e.g., PlayerButtonDown) you use passes a KEY_* enum, you can use the keys mentioned above.

For example, if you wanted a function to be called when they press the F keys:



-- clientside lua file
local binds = {
    [KEY_F1] = function() end,
    [KEY_F2] = function() end,
    [KEY_F3] = function() end,
    [KEY_F4] = function() end,
    [KEY_F5] = function() end,
    [KEY_F6] = function() end,
    [KEY_F7] = function() end,
    [KEY_F8] = function() end
}

hook.Add( "PlayerButtonDown", "Test", function( _, key )
    if ( binds[ key ] ) then
        binds[ key ]()
    end
end )


It should be mentioned that this hook is predicted which means that on clients it may be called multiple times per press in multiplayer and won’t be called at all in singleplayer.

Thanks a bunch all of you! :smiley: