5

I see that Linux has a more user-friendly version of the ALT codes used to type in special symbols. I need to be able to find an application that will accept and correctly interpret those alt codes, typical on Windows machines.

I have a portable word processor, an AlphaSmart. It holds some files in memory, but I often need to transfer these to my computer after writing them. When attached to a computer, it pretends it is an actual keyboard, and sends the text as if someone is typing. It just types really fast. So I just open mousepad and press "send" and it "transfers" the document from the AlphaSmart to the computer by typing it. Linux just thinks it is a keyboard plugged in that is typing.

When it comes to accented characters, it sends emulated ALT key combinations. But Linux doesn't understand those, so I end up with words missing the accents. "Hernán Cortés" is transferred as "Hernn Corts".

Is there a way to setup one single Linux application to accept these ALT codes so I can correctly retrieve the files with accent codes understood? Or is there a way to install an input method, such as through ibus that will accept ALT codes?

Village
  • 5,035
  • 15
  • 50
  • 84
  • 1
    What are ALT codes? Can you give an example? are you thinking of unicode characters? What Linux are you using? More importantly, what desktop environment and what keyboard layout? Does it work as you expect if you use a keyboard layout with "Dead keys"? – terdon Jul 19 '19 at 12:50
  • In Windows, you could type ALT plus a four-digit number to type in a special character. https://sites.psu.edu/symbolcodes/windows/codealt/ For instance, I used to type ALT+0176 to get the ° symbol to appear. I don't know if current versions of Windows still does this. I have the latest Debian with a US keyboard layout. I don't know how to use a keyboard layout with dead keys. – Village Jul 19 '19 at 12:54
  • Just use whatever GUI you have that lets you choose the keyboard layout and choose "English US, intl., with dead keys". That will let you use the right Alt to enter accents (e.g. LeftAlt+' and then type o and you get ó). – terdon Jul 19 '19 at 12:57
  • @terdon but that doesn’t help with the AlphaSmart input involved in the question :-(. – Stephen Kitt Jul 19 '19 at 12:58
  • What I'm saying is the AlphaSmart doesn't type LeftAlt+o, it types ALT+0243 when it wants to enter ó, and I can't change that behavior. How can I get Linux or one application at least to understand the ALT codes? – Village Jul 19 '19 at 12:59
  • Ah. Sorry, in that case I don't get what this Alpha thing is so I probably can't help. – terdon Jul 19 '19 at 13:07
  • This old thread between myself and David de la Harpe Golden shows some usage of xkb. Sorry it's a long meandering thread. Search setxkbmap – Rusi Jul 19 '19 at 13:10
  • Also pointless-xcompose shows some zany use of compose (dead key) – Rusi Jul 19 '19 at 13:19
  • Reading your question again it seems you want a special terminfo config setting perhaps?? https://unix.stackexchange.com/questions/73669/what-are-the-characters-printed-when-altarrow-keys-are-pressed – Rusi Jul 19 '19 at 13:30
  • Is there any way to configure the device to send some other keypresses instead? That would allow you to use Ctrl-u which terdon mentioned in their answer. Also, when it types ALT+1234, do the numbers actually get lost instead of being entered? On the ubuntu I tried, the numbers were passed through as-is. That might allow them to be replaced later. (though you'd still want to capture the points where alt was pressed to get an accurate result) – ilkkachu Jul 19 '19 at 13:57
  • Here's one answer on superuser that says the Linux text console does support ALT+1234 similarly to Windows: https://superuser.com/questions/1332822/emulating-alt-ascii-codes-in-linux – ilkkachu Jul 19 '19 at 14:01
  • If the AlphaSmart is plugged into a Mac, and then it will use some other Mac method to type in. However, I have no idea how to get it to think it is plugged into a Mac and there is no setting to force this. The AlphaSmart is a very simple device. – Village Jul 19 '19 at 19:58
  • When it types in Linux, the numbers after ALT don't appear on the screen. No character at all appears when it is trying to enter the special codes. – Village Jul 19 '19 at 19:59
  • @ilkkachu I have tested the console and it does indeed work. Simply switching to the console, then opening mcedit and then plugging in the AlphaSmart and sending works. – Village Jul 20 '19 at 02:35

3 Answers3

2

In most (all?) popular desktop environments, if you press Ctrl+u and then a Unicode code number, you will get the corresponding unicode character. For example, to get Ë, you would press Ctrl+u and then type 00cb.

Alternatively, switch to a layout with dead keys and this will let you enter accents using AltGr (right alt key). For example:

  • AltGr+' and then i gives í;
  • AltGr+` and then i gives ì;
  • AltGr+" and then i gives ï;
  • AltGr+: and then i gives °;
terdon
  • 242,166
  • The AlphaSmart stores text that I type. When I'm done with my file, I connect it to the PC with a USB cable, and press "Send" on the AlphaSmart, it, not me, types in the text. It emulates a person typing on the keyboard to transfer text to the computer. When connected to Linux, it detects a PC, and so it uses Windows-style ALT codes. I can't tell it to enter an alternative type of code, such as those you list here, it isn't so customization. – Village Jul 19 '19 at 13:15
  • @Village yeah, this is unlikely to help you. I'll leave it here in case it helps someone with a similar problem though. – terdon Jul 19 '19 at 13:22
  • That is okay, most people who actually use an AlphSmart aren't understanding how it works either. – Village Jul 19 '19 at 13:24
1

I'm not aware of any Linux input method which understands the MS-Windows style Alt+number input.

But you only need it to paste text from this external machine you own, so maybe this little Tcl script I wrote helps. It's a minimal text editor emulating those MS-Windows Alt+nnnn key sequences.

#!/usr/bin/wish

text .t
pack .t -fill both -expand yes

set buf {}
proc pressed {digit} {
    append ::buf $digit
    if {[string length $::buf] == 4} {
        .t insert insert [format %c [string trimleft $::buf 0]]
        set ::buf {}
    }
}

foreach k {0 1 2 3 4 5 6 7 8 9} {
    bind .t <Alt-KeyPress-$k> [list pressed $k]
}

You need Tcl and Tk to run it on your Linux box. Tell me if it works or if there are problems.

Janka
  • 486
0

I had exactly the same problem as you, and it eventually stopped me writing on the Alphasmart because I needed to use the "fada", the Irish accent on vowels: áéíóú.

This isn't a solution to the question as-asked, but I did just find this project which looks like it will finally let me use the Alphasmart once again:

https://github.com/lykahb/neotools

I have experienced a minor bug with this tool where it sometimes fails to switch the mode from "virtual HID keyboard" to "sync mode", but if you abort and try again a few times it seems to recover. Probably a small enough fix to the code to address this issue and meanwhile it's still usable.

Cathal
  • 1