¿Cómo puedo hacer que mis teclas de flecha ISO_Level5_Shift funcionen en las GUI de Java Swing?

¿Cómo puedo hacer que mis teclas de flecha ISO_Level5_Shift funcionen en las GUI de Java Swing?

Tengo una distribución de teclado que utiliza ISO_Level5_Shiftpara proporcionar teclas de flecha. Desde mi archivo de símbolos de diseño:

key <AC06> { type[Group1]="EIGHT_LEVEL", [ d, D, ampersand,  U2227, Home,  Home,  Greek_delta,   Greek_DELTA   ]};
key <AC07> { type[Group1]="EIGHT_LEVEL", [ h, H, parenright, U27E9, Left,  Left,  Greek_eta,     Greek_ETA,  U210F  ]};
key <AC08> { type[Group1]="EIGHT_LEVEL", [ t, T, parenleft,  U27E8, Down,  Down,  Greek_tau,     Greek_TAU     ]};
key <AC09> { type[Group1]="EIGHT_LEVEL", [ n, N, slash,      U2115, Right, Right, Greek_nu,      Greek_NU      ]};
key <AC10> { type[Group1]="EIGHT_LEVEL", [ s, S, underscore, U2237, End,   End,   Greek_sigma,   Greek_SIGMA   ]};

Estos funcionan en la mayoría de los programas (Firefox, Eclipse, Vim, ...). Desafortunadamente, no funcionan en ninguna GUI de Java Swing que haya usado. En particular, no funcionan en IntelliJ IDEA, y esto es lo que me ha estado molestando en particular.

¿Hay algo que pueda cambiar en mi diseño, en las variables de entorno relacionadas con Java o en la configuración de IDEA que pueda solucionar este problema?

Respuesta1

Bien, encontré una solución. No es realmente ideal, pero consigue el comportamiento deseado.

Primero, dejé elestado completode la configuración de mi teclado usando

$ xkbcomp $DISPLAY - > now.xkb

Entonces encontré las líneas

interpret Overlay1_Enable+AnyOfOrNone(all) {
    action= LockControls(controls=Overlay1);
};

y lo cambié a

interpret Overlay1_Enable+AnyOfOrNone(all) {
    action= SetControls(controls=Overlay1);
};

lo que evita que el modificador sea "pegajoso", es decir, solo se aplica mientras mantiene presionada la tecla.

Luego tomé la clave que solía ser mi ISO_Level5_Shift:

key  <TAB> {
    type= "ONE_LEVEL",
    symbols[Group1]= [ ISO_Level5_Shift ]
};

y lo cambié a Overlay1_Enable:

key  <TAB> {
    type= "ONE_LEVEL",
    symbols[Group1]= [ Overlay1_Enable ]
};

Luego, para cada clave en la que quería que el cambio surtiera efecto, agregué una definición superpuesta:

key <AD07> {
    type= "EIGHT_LEVEL",
    overlay1= <PGUP>,
    symbols[Group1]= [               g,               G,        asterisk,               G,           Prior,               G,     Greek_gamma,     Greek_GAMMA ]
};

Luego volví a aplicar todo con

$ xkbcomp now.xkb $DISPLAY

Documentación útil:

Respuesta2

También estaba teniendo problemas con esto, aquí está mi solución usando la tecla de bloqueo de mayúsculas como interruptor de superposición para habilitar la navegación tipo emacs/vim, espero que ayude a cualquiera que quiera hacer algo similar.

// Emacs like keys with CAPS as overlay switch.

// Using ISO_Level3_Shift or ISO_Level5_Shift would also make
// most applications work and would have been more flexible,
// however they don't work in Java Swing apps (e.g. IntelliJ IDEA)
// but using overlay works

// To enable, save this file as /usr/share/X11/xkb/symbols/emacs and run:
//
//   setxkbmap -option '' "emacs"
//
// However it may not persist and can get reset back to the default by other things.
// Alternatively, insert the following into /usr/share/X11/xkb/rules/evdev.xml
// ...
// <layoutList>
//   ...
//   <layout>
//     <configItem>
//       <name>emacs</name>
//       <shortDescription>en</shortDescription>
//       <description>English (US, Emacs)</description>
//       <languageList>
//         <iso639Id>eng</iso639Id>
//       </languageList>
//     </configItem>
//   </layout>
//   ...
// </layoutList>
// ...
// Then you should be able to choose 'English (US, Emacs)' in a keyboard preference
// GUI such as fcitx and have it persist.

default partial alphanumeric_keys
xkb_symbols "basic" {

    // Base keyboard functionality, using 'us' here
    // See definitions in /usr/share/X11/xkb/symbols
    // e.g. 'include "us(intl)"' where 'intl' is defined inside the 'us' file
    include "us"

    // Press Shift_L + Shift_R together as an alternative way to toggle Caps_Lock,
    // then turn CAPS key to enable overlay1 mode when and only when holding down.
    include "shift(both_capslock)"
    key <CAPS> {actions[Group1]=[SetControls(controls=overlay1)]};

    // Emacs like navigation keys when holding down <CAPS>
    // e.g. caps + n to go down
    key <AB05> {overlay1=<LEFT>}; // b
    key <AC04> {overlay1=<RGHT>}; // f
    key <AD10> {overlay1=<UP>  }; // p
    key <AB06> {overlay1=<DOWN>}; // n
    key <AC01> {overlay1=<HOME>}; // a
    key <AD03> {overlay1=<END> }; // e
    key <AC05> {overlay1=<ESC> }; // g

    // Emacs like editing keys when holding down <CAPS>
    // Redo/Undo only work with applications that understand the them
    key <AB10> {overlay1=<UNDO>}; // /
    key <UNDO> {[Undo, Redo]};    // Shift + / -> Redo
    key <AC03> {overlay1=<DELE>}; // d

    // VIM like navigation keys when holding down <CAPS>
    key <AC06> {overlay1=<LEFT>}; // h
    key <AC09> {overlay1=<RGHT>}; // l
    key <AC08> {overlay1=<UP>  }; // k
    key <AC07> {overlay1=<DOWN>}; // j

};

Respuesta3

En particular, no funcionan en IntelliJ IDEA, y esto es lo que me ha estado molestando en particular.

Existe una solución alternativa: asignar las claves deseadas en el lado de IntelliJ IDEA.

  1. Vaya a Configuración ⇒ Mapa de teclas.
  2. Busque una tecla que no funcione cuando se presiona la combinación de teclas "cambio de nivel iso" (digamos la tecla "Arriba").
  3. Elija "Agregar método abreviado de teclado".
  4. Presione la combinación de teclas "cambio de nivel iso" que no funciona como tecla "Arriba" en IntelliJ.
  5. Aplicar.

Voilà, la combinación de teclas “cambio de nivel iso” se comporta como la tecla “Arriba”inclusoen IntelliJ IDEA.

Respuesta4

Encontré otra solución, que requiere un poco más de trabajo, pero en última instancia funciona de manera más sólida en más software diferente.

La idea básica es omitir XKB yacceda directamente al mecanismo de manejo de eventos del kernel.

Una vez hecho esto, podrá controlar con precisión qué códigos clave ve todo el software.

Terminé creando unherramienta genérica de reasignación de clavespara lograr esto.

información relacionada