your code in keypress event in principe fires an error :
nkeycode is an integer and messagebox must receive a string :
messagebox(nkeycode)
must be turned on messagebox(trans(nkeycode))
i tested the code on a modal form (win10 and vfp9sp2) and it works properly for f9 or f10 pressed.
the messagebox is here.
these 2 keys not reserved by vfp ( as F1 ,shift+f9 or ctrl+f10....in this case they dont inetract and work as public key only for vfp).
the f9 and f10 keys become reserved vfp keys if they are combined with nshiftAltCtrl parameter:( see attached)
PROCEDURE Object.KeyPress
LPARAMETERS nKeyCode, nShiftAltCtrl
shift=1 or ctrl=2 or alt=4
for reserved vfp shortcuts see : [Keyboard Shortcuts (Visual FoxPro)] in help