Como posso fazer minhas teclas de seta ISO_Level5_Shift funcionarem em GUIs Java Swing?

Como posso fazer minhas teclas de seta ISO_Level5_Shift funcionarem em GUIs Java Swing?

Eu tenho um layout de teclado que ISO_Level5_Shiftfornece teclas de seta. Do meu arquivo de símbolos de layout:

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   ]};

Eles funcionam na maioria dos programas (Firefox, Eclipse, Vim, ...). Infelizmente eles não funcionam em nenhuma GUI Java Swing que eu já usei. Em particular, eles não funcionam no IntelliJ IDEA, e é isso que me incomoda em particular.

Há algo que eu possa mudar no meu layout, nas variáveis ​​de ambiente relacionadas ao Java ou na configuração do IDEA, que possa resolver esse problema?

Responder1

OK, encontrei uma solução. Não é realmente ideal, mas obtém o comportamento desejado.

Primeiro, larguei oestado completoda configuração do meu teclado usando

$ xkbcomp $DISPLAY - > now.xkb

Então eu encontrei as linhas

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

e mudou para

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

o que evita que o modificador seja "pegajoso", ou seja, ele só se aplica enquanto você mantém a tecla pressionada.

Então peguei a chave que costumava ser meu ISO_Level5_Shift:

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

e mudei para Overlay1_Enable:

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

Então, para cada chave onde eu queria que a alteração entrasse em vigor, adicionei uma definição de sobreposição:

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

Em seguida, reapliquei tudo com

$ xkbcomp now.xkb $DISPLAY

Documentação útil:

Responder2

Eu também estava tendo problemas com isso, aqui está minha solução usando a tecla Caps Lock como opção de sobreposição para ativar a navegação semelhante ao emacs/vim, espero que ajude quem deseja fazer algo semelhante.

// 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

};

Responder3

Em particular, eles não funcionam no IntelliJ IDEA, e é isso que me incomoda em particular.

Existe uma solução alternativa - mapear as chaves desejadas no lado do IntelliJ IDEA.

  1. Vá para Configurações ⇒ Mapa de teclado.
  2. Procure uma tecla que não funciona quando a combinação de teclas “iso level shift” é pressionada (diga a tecla “Up”).
  3. Escolha “Adicionar atalho de teclado”.
  4. Pressione a combinação de teclas “iso level shift” que não funciona como tecla “Up” no IntelliJ.
  5. Aplicar.

Voilà, a combinação de teclas “iso level shift” se comporta como tecla “Up”aténo IntelliJ IDEA.

Responder4

Encontrei outra solução, que dá um pouco mais de trabalho, mas que funciona de maneira mais robusta em softwares mais diferentes.

A idéia básica é pular o XKB etoque diretamente no mecanismo de manipulação de eventos do kernel.

Depois de fazer isso, você poderá controlar com precisão quais códigos-chave todo software vê.

Acabei criando umferramenta genérica de remapeamento de chavepara conseguir isso.

informação relacionada