inkey() is the wrong function overall as you actively use it to wait for a key at a certain position in code, how would you use that to wait for keys in a grid?
The lastkey() is ok, but you don't need it, when using the keypress event.
Use keypress of the textboxes within the grid, not keypress of the grid control itself. The grid is just the outer frame and record/deletion marks plus the grid lines. Users work within the grid column controls. They get the events (not only keypress, also interactivechange etc), not the grid control. The grid control is unimpartant for that matter.
The only other place you get all keypresses is the form.keypress, when you set form.keypreview=.t.
To have centralised code in the grid, you'd use BINDEVENTS() to bind all the keypress events of the columns controls to the grid.keypress and program your ENTER or ESC key behaviour there. Use the parameters passed in, not lastkey().
Bye, Olaf.