fix the bug where playScript function gets called more than once after pressing a key