← Back to team overview

kicad-developers team mailing list archive

Re: Modifier keys for hotkeys

 

Le 14/12/2014 03:02, John Beard a écrit :
> Hi,
> 
> I'm trying to get a hotkey defined as "Ctrl-Shift-D". Currently, I can
> make it work easily in GAL mode, but not in the legacy mode.
> 
> This seems to be because of the following code in draw_panel.cpp:
> 
>     if( event.ShiftDown() && (event.GetKeyCode() > 256) )
>         localkey |= GR_KB_SHIFT;
> 
>     /* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
>      * They have an ascii code from 1 to 27 remapped
>      * to GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z'
>      */
>     if( (localkey > GR_KB_CTRL) && (localkey <= GR_KB_CTRL+26) )
>         localkey += 'A' - 1;
> 
> The first check will refuse to set the shift modifier unless the keycode
> is more than 256 (so all normal letters fail this).
> 
> Secondly, the localkey is not remapped for cases other than Ctrl-<X>.
> (e.g. Ctrl-Shift-<X>).
> 
> I changed it to the following:
> 
>     if( event.ShiftDown() )
>         localkey |= GR_KB_SHIFT;
> 
>     /* ... */
>     if( ( localkey & ~( GR_KB_CTRL | GR_KB_SHIFT | GR_KB_ALT ) ) <= 26 )
>         localkey += 'A' - 1;
> 
> And the hotkey now works. Ctrl-D still works, as do the other hotkeys.
> Does anyone know why these two checks were made like this, and if this
> change is valid to make? I have attached a patch of the change.

Yes I know (for the shift key).
With your changes, many symbols are no more accessible because
many are accessible only with the shift key down many other only with
the shift key up.

For instance keys '0' to '9'  give a different ASCII code when shifted
and not shifted.
(Symbols '0' to '9' are accessible on a French keyboard with the shift
key pressed).

In other words, the key which generate '5' and '(' is the same on my
keyboard, therefore
I can only type 'Shift+5' and '(', but not 'Shift+(' and '5'

Only "ASCII" keys 'A' to 'Z' (or 'a' to 'z') can be used with the shift
key up or down.

> 
> This was all on Linux, in case there is some platform-dependent
> behaviour here.

This is not platform-dependent, but keyboard and locale dependent.

> 
> Cheers,
> 
> John


-- 
Jean-Pierre CHARRAS


Follow ups

References