HeliBoard icon indicating copy to clipboard operation
HeliBoard copied to clipboard

SHIFT-RETURN should output LINE FEED

Open atom-smasher opened this issue 1 year ago • 10 comments

Is your feature request related to a problem? Please describe.

Some apps interpret "Enter"/"Return" as "Submit", but "Line Feed" (0x0A) is needed.

Describe the solution you'd like Pressing "Enter" modified by "Shift" should produce a "Line Feed" (0x0A) character.

Use case When typing comments, Slim Social (FOSS Facebook app) has no option to interpret "Return" as "Line Feed", so comments are constrained to a single line. The only workaround I've found is to compose a comment in a text-editor, then copy and paste into Slim Social, where "Line Feed" is recognised as desired. Some apps have an option to interpret "Enter"/"Return" as a "Line Feed", but some apps don't have that option.

Describe alternatives you've considered (if any) Using a text editor, and copy-paste.

atom-smasher avatar May 30 '24 10:05 atom-smasher

This seems to already be working.

eranl avatar Jun 26 '25 00:06 eranl

I don't see this working. Enter always starts a new paragraph, not just newline. Not even when pressing SHIFT simultaneously.

treysis avatar Oct 28 '25 12:10 treysis

For me, when an app is configured to treat enter as submit, pressing shift before enter changes its icon to line-feed, and pressing it makes a new line. The distinction between a new line and a new paragraph is app-specific I believe, outside the keyboard's control.

eranl avatar Oct 30 '25 01:10 eranl

I think the underlying problem is that Android itself doesn't support combined key inputs. I.e., there simply is no SHIFT+ENTER in Android. It's either SHIFT OR ENTER.

That means, if an app wants to make a distinction between newline and new paragraph, it should implement capturing the SHIFT key, remember that state, and treat subsequent ENTER accordingly. Apparently, some apps do this already but the majority doesn't seem to.

treysis avatar Oct 30 '25 11:10 treysis

Part of me wonders if this is just how an app interprets "Enter" as a newline, carriage return, line-break, or something else. But… Even in apps that interpret "Enter" as some kind of "submit" button in a text-box or similar, I can paste text with multiple newlines, and that works fine as line-breaks.

In some apps, that's the inconvenient work-around: Type something in a text-editor with line-breaks where I want them, then copy-and-paste that text into the app. In my experience, that tends to work as desired.

The question then, is: What makes a line-break in copied text different from a line-break that I'd expect from "Enter"? Can this "pasted line-break" be emulated in the keyboard? In some other keyboards, I can save a shortcut (eg "nl" to be a copy-and-paste new-line from a text editor, but I can't seem to do that here.

atom-smasher avatar Oct 30 '25 12:10 atom-smasher

As far as I understand the new-line/line break character isn't the problem in itself. That's why copy&paste works. The problem appears to be that the keyboard interface in Android simply doesn't support modifiers. If you press "SHIFT+a" the keyboard doesn't send the key code for "SHIFT" & "a", but instead it simply sends the key code for "A". Would be interesting if a keyboard could introduce a custom key that would send newline instead of ENTER, but I am not sure if that is a supported key code in Android.

From what I've seen so far the very few implementations that use SHIFT modifiers is they monitor the keycode for SHIFT, save that state internally, and then do with the following key code what ever they think SHIFT+* should do.

treysis avatar Oct 30 '25 19:10 treysis

What if holding the "Enter" key presented some options, including newline, newline+CR, etc?

Again, what's special about copying and pasting a newline that's different than pressing "Enter"? Can that be done as an option by pressing and holding "Enter"? Could that even be the default, and "enter" is an option?

atom-smasher avatar Oct 30 '25 21:10 atom-smasher

Copy&Paste circumvents the keyboard, therefor it has nothing to do with how the keyboard sends keyboard events.

Not sure if one could modify the keyboard to effectively "paste" a newline instead of sending a key event.

treysis avatar Oct 30 '25 22:10 treysis

The keyboard has other "paste" functionality, so why not? Isn't this kind of how the shortcuts work? Apps seem none the wiser if I paste from the keyboard or type manually… But I can paste a newline without triggering a "submit".

atom-smasher avatar Oct 30 '25 23:10 atom-smasher

I dont think pasting actually comes from the keyboard, even if the keyboard initializes it.

I hope somebody will give this a try...Heliboard seems a good place. I myself cannot do it.

treysis avatar Oct 31 '25 01:10 treysis

As a workaround, I've found that redefining a toolbar key's keycode to "13" (carriage return) does the trick of entering a linebreak; maybe as an easy stopgap an extra toolbar button for "newline"/"enter" could be added, since mis-using one of the other toolbar keys seems a bit wrong? 🤔

KernelLeak avatar Dec 08 '25 09:12 KernelLeak

Why not use shift-return?

eranl avatar Dec 08 '25 17:12 eranl

Why not use shift-return?

Because it just sends messages in Firefox, for example Patreon comments...

KernelLeak avatar Dec 08 '25 17:12 KernelLeak

Any other examples?

eranl avatar Dec 08 '25 17:12 eranl

How to make shift+return send keycode 13 then? But i think many apps monitor shift key? Instagram? Facebook?

treysis avatar Dec 08 '25 20:12 treysis

It sends Line Feed (10, 0x0A "new line"), which is the normal enter key code, as requested in this issue. AFAIK, pressing Shift in itself doesn't send anything to the app.

eranl avatar Dec 08 '25 21:12 eranl

Ok, I am trying not to confuse line feed, carriage return, and what computers make of it...

We just need a way so send a newline without new paragraph (what enter does vs shift+enter on a normal keyboard).

treysis avatar Dec 09 '25 11:12 treysis

@treysis, I suggest you open a new issue, because it's different from this one.

eranl avatar Dec 09 '25 15:12 eranl

It might seem so, but the underlying issue is the same: Most Android keyboards cannot/do not send a simple newline, but just offer Enter which equals "submit" or "new paragraph". PCs offer the SHIFT key modifier, but Android lacks this option.

treysis avatar Dec 09 '25 16:12 treysis

In this issue, the ask was that in fields where the main action is "Submit" (Android IME_ACTION_SEND), pressing Shift-Enter would send a line feed instead. This issue is resolved AFAICT.

IIUC, you are asking for something else - that in fields where the main action is line feed, pressing Shift-Enter would send a simple newline instead.

Since this issue is resolved, there's no point in riding on it for your different one.

eranl avatar Dec 10 '25 00:12 eranl