Detecting newline

Using nul > layer('shift'), it seems that Keyman does not detect newlines. Is there a way to achieve this? Thanks.

[…] and at the start of the context it signifies that the context buffer in the application must be empty (or no longer than the context of the rule) in order for the rule to match.

The “context buffer” is not limited to the current paragraph; it refers to all text available. A new-line character should never will not consistently match nul. (The frequency of this may be platform-dependent - the point being that it’s not something to rely on for this kind of check.)

U+000A and U+000D are the two characters to check against for a new-line, so perhaps:

store(newline) U+000A U+000D

any(newline) > layer('shift')

might be what you’re looking for.

It seems like you’re aiming to do start-of-sentence group(PostKeystroke) related things, so in case you could use a reference:

If you ignore the deadkey parts of that (dk(1) / -dk), this is how our default keyboard for mobile apps handles most of the overall problem I think you’re looking to solve. (With this specific question just a part of the whole picture.) That said, note that it doesn’t auto-capitalize if you didn’t end the text before the new-line with punctuation. (I’m not actually sure if that’s even intentional… huh.)

This group is referenced by group(PostKeystroke), which filters out certain cases where we don’t want to let layer changes kick in - for example, when on the caps layer.

1 Like

Thanks @joshua_horton for your reply. Yes, I had already implemented the “PostKeyStroke” and “detectorStartOfSentence” groups, but as you also said, it doesn’t automatically capitalize if the text before the new-line doesn’t end with punctuation. That’s why I asked. But then I decided not to implement that feature at all, since I think it’s not a big deal after all to press the Shift button when needed.

Thanks anyway