How to make applescript hold a key for 2 seconds
You probably want key down &amp; up as separate events...

repeat 100 times
    tell application "System Events"
        key down {command}
        key down "w"
        delay (random number from 0.5 to 3)
        key up "w"

        key down "s"
        delay (random number from 3 to 4)
        key up "s"
        key up {command}
    end tell
end repeat


[untested as I've nothing to really test it on]
Now tested as working on a similar game structure.