Page 1 of 1

Using the Enter Key on a text Area for a new line

Posted: Wed Mar 25, 2009 5:14 pm
by Profound Logic
Question:

The Enter key is used to update and move to the next screen, however I need to be able to enter a new line on a text area. The Enter key needs to operate differently on a text area. Is this possible?

Response:

From my understanding of the problem, you need a function that handle key events and limits the enter key on a text area when it’s filled out.

You may need this JavaScript function in your custom.js file. Your custom.js file should be included within the skin’s folder you are currently working with. Assuming you are working with the Gradient Skin, the custom.js file should be under this path: /YourGenieDirectory/web/Skins/Gradient/custom.js

Add this function to the custom.js

Code: Select all

function handleKeyEvent(event) 

{
    if (!event) 
        event = window.event;
    if (event.keyCode == 13)         // Enter
    {  
       if (window.event) 
       {
            window.event.cancelBubble = true;
       }

       if (event.preventDefault) 
       {
            event.cancelBubble = true;
       }
   }

In the designer window, click on the textarea and find the “onkeydown” event in the properties window.

Add “handleKeyEvent()” in the “onkeydown” event to call the JavaScript function whenever the user presses any key detecting the enter key

Save your screen and reload the page


This should accomplish what you need