Detecting how long the button is held down?

I’m making a silenced aug with decent nightvision (no shitty color change in scope) and it uses a console command, “nightvision_on”. I have no idea to detect how long the second mouse has been held down, so I can only make it activate when mouse2 is pressed, but the scope-in is a hold-down mouse type of thing.

[lua]function SWEP:SecondaryAttack()
timer.Simple(0.3, game.ConsoleCommand, "nightvision_on 1
I want to know if something like this exist
[lua]if self.owner:KeyIsDown(Mouse2) = true // obviously key doesn’t exist, but its just showing what I want
then timer.Simple(0.3, game.ConsoleCommand, "nightvision_on 1

function SWEP:Think()

if self.Owner:KeyDown(IN_ATTACK2) and !self.Owner:KeyDownLast(IN_ATTACK2) then //First time pressed

    self.Timer = CurTime()+0.3

if !self.Owner:KeyDown(IN_ATTTACK2) then

    self.Timer = nil

if self.Timer and CurTime()-self.Timer < 0 then

    //Turn on nightvision (dont use a concommand, gawd!)


oh… self.Owner:KeyDown…
one word off.



oh and thanks for the help, as you seem to be the over-ruling god of the newbie questions in the lua section.