Comment by ๐Ÿš€ lanterm

=> Re: "How to provide configurable keyboard shortcuts to users of..." | In: s/programming

For a source of truth, I'd consider the key code that the application receives when the user presses the key. I'd treat modifier keys specially (ctrl, alt, shift, meta) and then take any other key code literally.

To write these combos to a file, you'd use whatever you want to represent this collection, like an array of symbols, but that depends on the programming language and your preferences for serialization.

e.g.

copy: ctrl+

find/replace: ctrl+shift+

To that end, you'd likely need to provide some area of the settings for the user to create their own key bindings.

=> ๐Ÿš€ lanterm

2024-05-06 ยท 9 months ago

3 Later Comments โ†“

=> โ˜•๏ธ Morgan ยท 2024-05-06 at 06:31:

This gets really hard when you consider multiple keyboard layouts, I suggest looking for prior art, e.g.

https://wiki.archlinux.org/title/xmodmap

=> ๐Ÿฆ€ jeang3nie ยท 2024-05-06 at 14:06:

As Morgan said, this gets complicated when you take into account different keyboard layouts (and you definitely shouldn't ignore this). For that reason I would suggest looking at whether the toolkit you are using has already solved the problem, assuming you're using a toolkit and not basically writing your own like Skyjake did. I know gtk+ can capture key presses and translate the codes into the appropriate symbol for you, based on the key map. I've used that facility.

=> ๐Ÿ›ฐ๏ธ lufte [OP] ยท 2024-05-06 at 14:37:

I am using a toolkit and, since the last version, it provides a great level of abstraction over this. I get to choose between the hardware keycode, the virtual keycode (after layouts and re-mappings), and the actual character being written by the key press (if any). I'm mostly conviced of choosing the latter, when available, but I'm still unsure about the modifier. If ':' can only be produced by pressing Shift, should the "Shift+:" and ":" bindings both work or only the first one?

Original Post

=> ๐ŸŒ’ s/programming

How to provide configurable keyboard shortcuts to users of my application? โ€” I'm writing a desktop app that provides configurable keyboard shortcuts. For now these are set up by writing key sequences to a file. Of course, something that sounds straightforward stops being so as soon as you get past the surface. I am now trying to figure out what's more "intuitive" (if such thing even exists) when you're trying to serialize a sequence of keystrokes to text. For example, let's say you have a US...

=> ๐Ÿ’ฌ lufte ยท 4 comments ยท 2024-05-05 ยท 9 months ago

Proxy Information
Original URL
gemini://bbs.geminispace.org/u/lanterm/16608
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
55.559863 milliseconds
Gemini-to-HTML Time
0.883354 milliseconds

This content has been proxied by September (3851b).