Need help with IsKeyDown()

I testing this and iv got five time spawn word “Good!” in console how to make it spawn once?
[LUA]
local function Test()
if input.IsKeyDown(KEY_M) then
print(“Good!”)
return
end
end
hook.Add(“Think”, “Test”, Test)
[/LUA]

[LUA] if input.IsKeyDown( KEY_M ) and IsFirstTimePredicted() then [/LUA]

keep in mind prediction in gmod is fucked

Doesn’t work for me

[LUA]
local function Test()
if input.IsKeyDown(KEY_M) then
print(“Good!”)
return
end
end
hook.Add(“Think”, “Test”, Test)
[/LUA]


local old = false
hook.Add("Think", "Test", function ()
    if input.IsKeyDown(KEY_M) && old != input.IsKeyDown(KEY_M) then 
        print("Good!")
    end
    old = input.IsKeyDown(KEY_M)
end)

[del]If serverside and multiplayer, you’ll need separate ‘old’ variable for each player. Ran into this issue myself just last night.[/del]

EDIT: I’m wrong, was thinking of CMoveData:KeyDown

input.IsKeyDown() is clientside only

My bad, I was thinking of CMoveData:KeyDown