Detect newline keypress in TextFiled and TextArea?

Is there a way to detect when the Enter/Return key is pressed in an event handler for a TextField or TextArea?

Checking for Key = EOL in KeyDown does not appear to work.
Best I’ve been able to do for a TextArea is to detect when the last character of the Text = EOL,
however even this is problematic since it does not appear to trigger until the next character
AFTER the EOL char has been appended. Works fine for other non-EOL characters.

I’d like to find solutions for both TextField and TextArea, which may differ.

In the KEYPRESS event of EITHER control… check for CHRB(10) or CHRB(13) or CHRB(3)
if any of those key values appear then either the [RETURN] or [ENTER] key was pressed

If you wish to handle it youself and NOT transfer that key press to the control, be sure to have the event return TRUE

That works here, but try this:

select case key.Left( 1 ).Asc
case 10, 13
// EOL

// Something else


You can also use Keyboard.AsyncKeyDown to check for those two keys.