Unexpected-Keyboard icon indicating copy to clipboard operation
Unexpected-Keyboard copied to clipboard

Variables as keys

Open WubTheGame opened this issue 1 year ago • 9 comments

For my particular case, I'd like a "key" that inputs the current time (and optionally the date). I recognize this is variable thing, and it could be cool to have a more flexible system than just for this one thing, so I'll leave that as a suggestion for later down the road, hoping this one function would be quicker and easier.

Also, it'd be nice to be able to configure keys to input text directly to the clipboard (whether text is selected or not) to trigger MacroDroid macros. It has a Clipboard Change trigger.

Thank you for this keyboard in advance and regardless.

WubTheGame avatar Dec 04 '24 20:12 WubTheGame

The date/time has been suggested before: https://github.com/Julow/Unexpected-Keyboard/issues/228 It's unclear what a more flexible system could look like or what it would offer. Thought, I'm not against a key that would output the current date and/or time, perhaps taking the silly date/time patterns from Java or having two keys for date and date with time.

Could you implement it ?

I'm also not against the specific text to clipboard idea. The "complex" key syntax would allow to describe this kind of keys in layouts: https://github.com/Julow/Unexpected-Keyboard/blob/master/doc/Possible-key-values.md#complex-keys

Julow avatar Dec 04 '24 22:12 Julow

I meant a more flexible system as in multiple variables and all that that you can manage. Though perhaps what I'm thinking of is more like a mini-scripting system (I am at least a fair bit of a power user). What I picture is creation of fixed keywords you type to trigger fixed or variable text or operations. Like typing a short string as an alias to output a longer one.

Anyway, I'd love to try implementing it, but my programming expertise only goes as far as AutoHotkey. I'm certainly no android developer (though I understand from elsewhere in these threads that things can be tested on PC). If you could point me in the right directions for figuring out how I might be able to (files in the repo to edit, general idea of what to go for code-wise), I'd be open.

WubTheGame avatar Dec 05 '24 05:12 WubTheGame

Do you have a list of the variables you are mentioning. I think this is a little vague and that's why I'd suggest starting small with the date and time keys so it starts to solve problems. A scripting language within the keyboard is out of the question without compelling use cases. This app is meant to remain light.

Julow avatar Dec 07 '24 21:12 Julow

Fair enough. Don't mind me going on about the variable system, I can get way ahead of myself with these things. By this I mean I have general ideas as in a number of "aliases" you can program different outputs for, but besides current time/date I don't know what in particular would be useful and non-fixed. Like having an alias system, and you can set an alias to output a variable and/or fixed value/sequence of characters. Just something to consider eventually.

....And before sending, I realize the only thing really new about this suggestion is the variables part since you can already set custom keys that output whatever and however many characters you want. So, take this with what you will then.

WubTheGame avatar Dec 07 '24 23:12 WubTheGame

The notion of date and time reminds me of an old scripting language in which matching accent-grave characters meant, "Submit the enclosed string to the shell and replace the entire expression with the shell's output." Ah, but next you'll want functions to edit the string…

Spike-from-NH avatar Dec 08 '24 17:12 Spike-from-NH

💡 I remember using in the past a keyboard that would like do stuff such as print out comment syntax <-- --> and place the cursor back in between.

ChiefMikeK avatar Dec 14 '24 10:12 ChiefMikeK

@ChiefMikeK, this is an easier request than date/time. The emerging complex syntax in custom layouts, when completed, ought to let you map a key to the comment characters followed by a suitable number of left-arrow strokes.

Spike-from-NH avatar Dec 14 '24 10:12 Spike-from-NH

hi there,

to let you map a key to the comment characters followed by a suitable number of left-arrow strokes.

was this impemented?

Also, it'd be nice to be able to configure keys to input text directly to the clipboard (whether text is selected or not) to trigger MacroDroid macros. It has a Clipboard Change trigger.

looks weird

Like typing a short string as an alias to output a longer one.

that sounds good

Submit the enclosed string to the shell and replace the entire expression with the shell's output." Ah, but next you'll want functions to edit the string…

i havent use very much the KEY_EVENT feature, but couln't you send the event with a selected text as extra info (i dont't know if this is remotely possible) and replace that text with the text returned (if any, and probabily asyncronously)???

BTW, who can listen to those events? Any app? Only the app under the keyboard?

simper66 avatar Sep 14 '25 06:09 simper66

Yes, it was implemented in v1.31. It's documented here.

Example: <key c="y" nw="you:You,cursor_left,cursor_left">

Spike-from-NH avatar Sep 14 '25 09:09 Spike-from-NH