I've fallen in love with being able to hold down on a key on Android for about 100ms to get a punctuation key 'beneath' it (otherwise found in the menu), and I'd love to have that same ability for Ubuntu. I don't need to repeat characters, so I wouldn't be missing anything. Is this possible, and if so, how? Thank you :)
There isn't currently any quick and easy way to enable this kind of functionality on the desktop version of Ubuntu.
Personally I'm a big fan of the default compose key shortcuts; I find them faster and a lot more intuitive than mobile-style long press selection (♥). That said, if you have the time and determination, you might be able to piggyback the slowkeys option in the default core Universal Access application to build something similar to the mobile option.
Poking around in that myself, XKB seems to be associated with slowkeys control. You can use XKB to configure and enhance Ubuntu's keyboard bindings, and as far as I can tell, this section has what you need. So it shouldn't be that (relatively) difficult to have an alternative character print when a key is long-held.
Where things get complicated is assigning multiple special characters to a keystroke (example: hold down "a" and get options for ä, à, á, â, etc.). How do you cycle through the options? Do you have the characters pop up in a dialogue window, then use the mouse, tab or arrow keys to select one? Seems time consuming.
Or you could assign different hold lengths to different characters. 100ms hold for à, 200ms hold for á, 300ms for â... But remembering how many seconds are for which characters could get tricky, not to mention assigning all of them individually would be a headache. Plus when you get into longer lists of characters you could be sitting there holding a key for a good 3-4 seconds. Seems even more time consuming.
Rather than slowkeys, you could try the repeatkeys option instead to have multiple taps of a key provide a special character: 3 taps of "a" for à, for instance. But then you run the risk of having unwanted special characters popping up when you type anything like "good", or "eerie", or "aaaaaaahhh!"
You may have come up with some other, more efficient implementation method that I'm not thinking of, in which case go forth and modify! But I'll still recommend compose key combinations in the meantime. ☺
I'm certain that this is possible to do by modifying the keyboard interrupt service routine (ISR). Whenever a key is pressed, an interrupt signal is sent to the CPU. The CPU will then service that interrupt by running the keyboard ISR.
ISR's are low-level programs, typically coded in assembly language, because they deal directly with hardware and must be fast. Here is more info on hardware interrupts on the Intel processors and how to use them.
Keyboards have had their own processors since the days of the original IBM-PC, and can generate characters very rapidly if any key is held down.
A couple of definitions might be useful here:
Repeat Delay: The time lapsed between pressing the key and when it starts repeating.
Repeat Rate: After a key is pressed, the keyboard will repeat that key. The speed at which it repeats is the repeat rate. Sometimes called the typematic rate.
The keyboard ISR routine would have to be modified to substitute the Repeat Delay function for an 'Alternative Character' function. The timing of the key press and release is the essence of it. By measuring the duration of the key press, the ISR (or interrupt handler) would know to pass on either the normal character of the alternate character (the key "beneath" it)
Essentially, you would be modifying or re-writing the device driver for the keyboard.
This is just a high-level view of the approach I think would be needed to achieve what you want.
Because the touchpad functions similar to the touchscreen in Android it would provide a better interface than the keyboard. Indeed a whole new set of routines could be implemented to zoom by moving thumb and forefinger together and zoom out by reversing direction could be implemented.
The touchpad can already sense one-finger, two-fingers, even palms accidentally moving against the touchpad and hence ignored. Acceleration and deceleration speeds are recognized. It's already controlling the mouse pointer for the text you'd want to highlight with a long press.
It should be a piece of cake for programmers to add an extra bit of code to measure touch press length and bring up a context sensitive menu for
paste, etc like the smartphones do today.
I think your question is a great idea that can evolve software and keyboards with builtin touchpads to a whole new level. I should point out that some touchpads built into keyboards have a colour lcd screen which could take your idea even further. ie, screen text being highlighted can be mirrored to the touchpad lcd and zoomed in for fine movements.
Apple, Google, Microsoft and Linus could all be excited with your idea. It's certainly piqued my interest!