dr*****@yahoo.com wrote:
The ENTER key functionality used by textarea is built into the browser
by default...I'm not sure you can trap this and use a different key
(JavaScript is much more limited than a desktop lanaguage like C++ or
Java).
JavaScript, or ECMAScript implementations for that matter, was never
intended to be a "desktop language". And the features you describe are
not language features; they are features of the DOM (Document Object Model)
of the execution environment (here: browser) it runs in, which exposes
ECMAScript language binding for its interfaces to client-side scripting.
For example:
<URL:http://www.w3.org/TR/DOM-Level-2-Events/ecma-script-binding.html>
I would look at the "keypress" event of the textarea control,
True.
and use window.event.KeyCode to check the keystrokes and see if you can
^^^^^^^^^^^^^^^^^^^^ trap the ENTER key press and route it to another.
That assumes there is an object that can be referred to with window.event;
however, that is proprietary and restricted to IE only. It also assumes
that ECMAScript implementations are case-insensitive, which they are not.
A cross-browser (but due to the proprietary `event' value
not fully standards compliant) approach would be
function handleKeyPress(e)
{
if (!e) e = window.event;
if (e && e.keyCode == 13)
{
// handle Enter key
// return false; here to cancel the event
}
}
<textarea onkeypress="return handleKeyPress(event);">...</textarea>
However, users do not like it very much when you interfere with their
working environment without a very good reason for doing so:
<URL:http://codestyle.org/javascript/FAQ.shtml#suppressctrln>
PointedEars
--
Multiple exclamation marks are a sure sign of a diseased mind.
-- Terry Pratchett