# Hotkeys with Lua script



## FakiR (Sep 13, 2019)

Hello!
I want to write a script that will write an increasing value to a file. The script code is in the attachments.
It works, but the hotkey works twice. When a hot key is pressed once, the value 2 will be written to the file, not 1.
Where did I make a mistake?


----------



## Mango (May 10, 2021)

I have the same problem.  The function appears to fire both on key down and key up.  Any suggestions would be appreciated.

Using 26.1.1 on Windows.  Nothing appears in the log.


----------



## Mango (May 10, 2021)

I figured out how to fix it:


```
function instant_replay(pressed)
 if not pressed then
  return
 end
 team1_score = team1_score + 1
 write_to_file("team1", team1_score)
end
```


----------

