I think there's a bug with F5 key event actions. On my windows laptop anything I assign to F5 key or F5 (released) doesn't seem to execute with VS. I know the F5 key on my keyboard works though as I often use it to quickly refresh website pages.
As for the code, I must have gotten it from Simon or a script that he or David shared. It seems that key events seem to need those input variables for some reason, whereas mouse events can be triggered with a single input variable, for example...
createEvent('eEvtMouseLeftButtonDown'); createEvent('eEvtMouseLeftButtonUp') -- simulate left mouse button click
P.S: try swapping the F5 (released) to F12 (released) or C (released) or something else & see if the screenshot thing works.
P.S.S: screenshot requires the folder you are saving the screenshots to already exist otherwise VS won't generate the screenshot.