Using itempressed you can evaluate a click (mouse or keyboard)
windowevent itempressed 1
return no_action
If you want to overwrite or catch a SAP-function you have to use preitempressed
windowevent preitempressed 1
if <stationname> = whs then
// Station whs is locked
return success
end if
return no_action
Forms can have special modes.
Especially the Button "OK" has different functionality depending on the mode (refresh, add etc.). You can get the mode with form=mode (see form).