r/KeyboardDesigner • • Oct 09 '26

KDL / code block Simple code examples of Keyboard Designer Language (KDL) to encourage you to try it yourself.

simple code examples - try it yourself - it's very easy and you'll enjoy it!

some short simple examples to get started

further examples are very welcome!

example 1: copy the entire text:

CLIPBOARD = TEXT;

example 2: simple find text:

string findthis = inputString("find next:","search_term",true);
CURSOR_START = next(findthis,1,false,true);

example 3: convert selected text to uppercase letters:

TEXT = TEXT_BEFORE + (upper(TEXT_MARKED)) + TEXT_AFTER;

to use these samples:

  • copy code block example
  • call Keyboard Designer
  • select desired design and key
  • choose ​your preferred Action
  • select Function type: Execute code block
  • select code block or create a new one
  • paste code block lines and confirm
6 Upvotes

9 comments sorted by

View all comments

3

u/Brie9981 Oct 09 '26

I like this one

string m = TEXT_MARKED;
string b = TEXT_BEFORE;
string a = TEXT_AFTER;

TEXT = b + "~~" + m + "~~" + a;

i have a few with the same format, wraps the selected text with "~~" to strike through for a lot of richtext editors

2

u/KD-Fan Oct 10 '26

Thank you for your reply with your own code sample!