htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0:
Switching Enter key behaviour


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


aennenbach
New User

Apr 24, 2003, 2:41 AM

Post #1 of 5 (2207 views)
Shortcut
Switching Enter key behaviour Can't Post

Hi there,

first, i have to congratulate you for this magnificient piece of software. Good work!

Like other user, i don't like the standard behaviour of the Enter key: Enter = <P></P>; Shift+Enter = <BR>.
I searched thru your forum to find a solution to switch this behaviour, but i didn't found anything which meets my requirements, so i had to find a solution my self.

And i was successfull:
I changed the original code from:


Code
  // cancel ENTER key and insert <BR> instead  

if (ord == 13 && editEvent.type == 'keypress') {
editEvent.returnValue = false;
editor_insertHTML(objname, "<br>");
return;
}



to:


Code
  // cancel ENTER key and insert <BR> instead  
if (shiftKey == false && ord == 13 && editEvent.type == 'keypress') {
editEvent.returnValue = false;
editor_insertHTML(objname, "<br>");
return;
}else if (shiftKey == true && ord == 13 && editEvent.type == 'keypress') {
// SHIFT + ENTER = <P></P>
editEvent.returnValue = false;
editor_insertHTML(objname, "<p>", "</p>");
return;
}



With this modification, the behaviour of the Enter key is switch, means: If the user presses Enter, a <BR> is inserted; If the user presses Shift + Enter, a Paragraph (<p></p>) is inserted.

I hope this will help somebody.

Regards,

aennenbach


Benjamin
Staff


Apr 28, 2003, 11:40 AM

Post #2 of 5 (2150 views)
Shortcut
Re: [aennenbach] Switching Enter key behaviour [In reply to] Can't Post

Excellent, thanks aennenbach! No doubt this will help people - we often have people inquiring after replacing <p>'s with <br>'s - but that breaks the list functionality (<ul>, <ol>). This allows those people to have best of both worlds.

Much appreciated. Smile
Ben
interactivetools.com


barcsdad
Novice

May 6, 2003, 3:07 PM

Post #3 of 5 (2093 views)
Shortcut
Re: [Benjamin] Switching Enter key behaviour [In reply to] Can't Post

I was eager to try this fix out, but it still seems to break the functionality of lists (<ol> & <ul>). Any thoughts?

Marty


Benjamin
Staff


May 7, 2003, 5:29 PM

Post #4 of 5 (2037 views)
Shortcut
Re: [barcsdad] Switching Enter key behaviour [In reply to] Can't Post

You're right, drat. I'd hoped it would interpret the closing </p> tag as ending the </li>... what a pity. I wonder if there'd be a way to bubble a carriage return event instead of explicitly writing </p>, </p> to the page...

Thanks for your post.
Ben
interactivetools.com


kojoman
Novice

Jul 11, 2003, 4:29 AM

Post #5 of 5 (1860 views)
Shortcut
Re: [barcsdad] Switching Enter key behaviour [In reply to] Can't Post

Hi. Did anyone also notice that either of the two functions, both the built in and yours, linebreaks the above row if you enter a link at the end of a row

Add a line of text and finish the line of by adding a link.
Now press enter.

actual results: inserts a <br> at the beginning of the row
expected results: insert a <br> at the end of the row (the cursor position)
-Johan

 
 
 


Search for (options)