The answer is you can't, you could of course use libcod which has build in these functions but there's an easier way.
1. Create a menu file and do something like
PHP Code:
bind k "openscriptmenu keys key_K"
2. On connect open the menu on each player so that it binds the right response to right key (eventually can do this as well on respawn to prevent players from changing it)
3. In menus.gsc make a new response like
PHP Code:
if(menu == "-1" && response == "key_K")
Then... execute your script.
Code untested, there might be an obvious to fix mistake but you should be able to fix it if any occurs.