Syntax

on keyDown what
  if what is newline then
    ...
  else
    pass keyDown
  end if
end keyDown

Explanation

Whenever you press a key on the keyboard, the current text field receives a keyDown .

See Also