"Enter" to create an BR tag instead of a P

"Enter" to create an BR tag instead of a P

by Di Juwel -
Number of replies: 5

when a user is in the atto editor and clicks "Enter" on keyboard, it creates a "<p>" tag.

I would like it to create a "<br>" tag instead.

how can that be done ?

and I know CTRL+Enter does it but I want "Enter" to do it too.

 

i'm using moodle 2.7

Average of ratings: -
In reply to Di Juwel

Re: "Enter" to create an BR tag instead of a P

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

Shift + Enter is how I do this. Same in Microsoft Word. I have not heard of customizing keyboard shortcuts in Moodle. 


https://docs.moodle.org/28/en/Text_editor_FAQ

In reply to John Provasnik

Re: "Enter" to create an BR tag instead of a P

by Di Juwel -

yes, i know "shift+enter" does it but i want it to be done with "Enter"

there must be somewhere in the code to do it.

In reply to Di Juwel

Re: "Enter" to create an BR tag instead of a P

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

You may look in lib/editor/atto/yui/src/editor/js/editor.js and change the line

document.execCommand('DefaultParagraphSeparator', false, 'p'); 

to use br tag. You will need to run shifter after you make the change. I do not know whether this is supported in all browsers.

In reply to Daniel Thies

Re: "Enter" to create an BR tag instead of a P

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

I am not sure exactly whether this addresses the problem.  This may be a browser issue (perhaps Safari). I think that Safari has different behavior with regard to shift enter. Safari changes enter to BR normally while other on browsers it inputs a P. Changing this code will result in all users entering BR on enter, not just those on Safari.