LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   alt key not working in nano (https://www.linuxquestions.org/questions/debian-26/alt-key-not-working-in-nano-417774/)

johnMG 02-20-2006 08:37 PM

alt key not working in nano
 
I'm using IceWM on Debian Etch and trying to get nano to work, but it's not listening to me when I hit the alt key.

For example, to move the cursor down-by-paragraph, alt-0 inserts a funny "degree" symbol (like a super-scripted zero). But ESC 0 works just fine.

I've tried emacs, which uses the alt key extensively, and it works fine with emacs.

The nano help screen refers to the "meta" key, rather than the alt key.

How can I get the alt key to behave properly?

johnMG 02-21-2006 09:15 AM

Ok. Update: the left alt key works in the console. It's X (or IceWM) that's possibly intercepting that left alt key.

I've got a programmable keyboard, so I can remap the right alt key to give the same output as that left alt if need be.

Any other icewimmers out there see this problem?

dracae 02-21-2006 03:51 PM

The problem is that the left alt key sends Alt_L to the X server while the right one sends Meta_R.
You should be able to solve the problem with
xmodmap -e "keysym Alt_L = Meta_L"
you can also add
keysym Alt_L = Meta_L
to ~/.xmodmap to make it persistent.

I may be completely backwards, I cannot check it at the moment. It may need to be
xmodmap -e "keysym Alt_L = Alt_L"

johnMG 02-21-2006 07:39 PM

> The problem is that the left alt key sends Alt_L to the X
> server while the right one sends Meta_R.

Well, that may be the problem when using the console (what's
the "console" version of xev?), but from IceWM, both Alt keys
seem to work fine in everything except nano.

I posted this to the IceWM ML, but in case it's useful to
someone else here, the details on my system are:
Code:

$ xmodmap -pm
xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift      Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control    Control_L (0x25),  Control_R (0x6d)
mod1        Alt_L (0x40),  Alt_L (0x7d),  Meta_L (0x9c)
mod2        Num_Lock (0x4d)
mod3     
mod4        Super_L (0x7f),  Hyper_L (0x80)
mod5        Mode_switch (0x5d),  ISO_Level3_Shift (0x7c)

xev tells me about my left and right:
Code:

KeyPress event, serial 30, synthetic NO, window 0x1000001,
    root 0x4c, subw 0x0, time 2364813, (424,-216), root:(430,615),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x1000001,
    root 0x4c, subw 0x0, time 2364965, (424,-216), root:(430,615),
    state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes:


KeyPress event, serial 30, synthetic NO, window 0x1000001,
    root 0x4c, subw 0x0, time 2365924, (424,-216), root:(430,615),
    state 0x0, keycode 113 (keysym 0xffea, Alt_R), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x1000001,
    root 0x4c, subw 0x0, time 2366068, (424,-216), root:(430,615),
    state 0x8, keycode 113 (keysym 0xffea, Alt_R), same_screen YES,
    XLookupString gives 0 bytes:

And the relevant parts of "xmodmap -pk" show:
Code:

    KeyCode    Keysym (Keysym) ...
    Value      Value  (Name)  ...

    64        0xffe9 (Alt_L)  0xffe7 (Meta_L)
    113        0xffea (Alt_R)  0xffe8 (Meta_R)
    115        0xffeb (Super_L)
    116        0xffec (Super_R)
    125        0x0000 (NoSymbol)      0xffe9 (Alt_L)
    127        0x0000 (NoSymbol)      0xffeb (Super_L)
    128        0x0000 (NoSymbol)      0xffed (Hyper_L)
    156        0x0000 (NoSymbol)      0xffe7 (Meta_L)


dracae 02-21-2006 07:46 PM

See if there is a change with xmodmap -e "keysym Alt_L = Meta_L"

Edit: sorry misread the above.

kloss 02-21-2006 07:46 PM

Quote:

Originally Posted by johnMG
what's the "console" version of xev?

You can give "showkey" a try...

johnMG 02-21-2006 08:18 PM

Ran:
Code:

$ xmodmap -e "keysym Alt_L = Meta_L"
as myself (not root).

Still the same problem with nano.

Now, the output which differs with what's posted above:

$ xmodmap -pm
Code:

mod1        Meta_L (0x40),  Meta_L (0x7d),  Meta_L (0x9c)
$ xev, hitting the left Alt key:
Code:

KeyPress event, serial 30, synthetic NO, window 0x1600001,
    root 0x4c, subw 0x0, time 4880742, (133,-51), root:(1549,940),
    state 0x0, keycode 64 (keysym 0xffe7, Meta_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x1600001,
    root 0x4c, subw 0x0, time 4880886, (133,-51), root:(1549,940),
    state 0x8, keycode 64 (keysym 0xffe7, Meta_L), same_screen YES,
    XLookupString gives 0 bytes:

$ xmodmap -pk
Code:

    64        0xffe7 (Meta_L)
    125        0xffe7 (Meta_L)


johnMG 02-21-2006 08:25 PM

> You can give "showkey" a try...

Thanks kloss. From a console, showkey tells me
Code:

left Alt:

    down  0x38
    up    0xb8


right Alt:

    down  0x64
    up    0xe4


dracae 02-21-2006 09:10 PM

Try setmetamode esc or setmetamode meta. This is per tty, if it works you can add something like this to your rc.local, or equiv.(taken from manpage)

INITTY=/dev/tty[1-8]
for tty in $INITTY; do
setmetamode escprefix < $tty
done

kloss 02-21-2006 09:15 PM

Quote:

Originally Posted by dracae
See if there is a change with xmodmap -e "keysym Alt_L = Meta_L"

That may be dumb but why isn't it :
xmodmap -e "keysym Alt_L = Alt_R" ?

dracae 02-21-2006 09:33 PM

Ok, got a little confused. First I thought the problem was in X, then the console, now X again. I am back on track, so disregard my previous post. What terminal emulator are you using? Do you have the same problem in others? xterm, Eterm, aterm, konsole, gnome-terminal?

johnMG 02-22-2006 01:43 AM

Quote:

Originally Posted by kloss
That may be dumb but why isn't it :
xmodmap -e "keysym Alt_L = Alt_R" ?

I think it's because X's rule is: "make whatever keycode that would usually result in a lhs_sym to instead generate a rhs_sym". So, dracae wanted me to tell X: "make whatever keycode that would usually generate an Alt_L instead generate a Meta_L" -- which would seem to make sense, since GNU nano is supposed to want a Meta when I hit my Alt key.

I'm trying to figure out what the issue is here, and in doing so am putting up a short help doc on the subject: http://www.simisen.com/jmg/keycode_keysym_keymap.html

Any input welcome, of course, especially since I've still got a couple of XXX's in that doc.

Thanks,
---J

johnMG 02-22-2006 01:57 AM

> Ok, got a little confused. First I thought the problem was in X,
> then the console, now X again.

I've got two separate problems:

1. In X, neither Alt key works with nano. They instead print funny little characters into my text file, and

2. In the console, only my left Alt key works in nano.

And now my third concern in understanding how all this works is, when I use "showkey", I seem to get a different keycode than I see with xev.

BTW, dracae, I've only ever used xterm. I just installed aterm, and [ ...drumroll...] nano works fine -- but this is with your xmodmap -e "keysym Alt_L = Meta_L" in effect.

I tried reversing that by running xmodmap -e "keysym Meta_L = Alt_L", and everything *still* works correctly in aterm. Weird. But nice. :) I wonder what the deal here is...(?)

Thanks.
---J

dracae 02-22-2006 08:53 AM

OK, in xterm ctrl+left click. You should have 2 options, Alt sends escape and Meta sends escape. Try those to see if you get the desired effect.

johnMG 02-22-2006 09:26 AM

> OK, in xterm ctrl+left click. [snip]

dracae, I select the "Meta Sends Escape" item, and both Alt keys in nano now work! :)

Thanks!


All times are GMT -5. The time now is 02:03 AM.