This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Hot keys must work in any keyboard layout
Type: enhancement Stage: resolved
Components: IDLE Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Nashev, THRlWiTi, christian.heimes, georg.brandl, gpolo, gvanrossum, kbk, r.david.murray, rhettinger, taleinat
Priority: low Keywords:

Created on 2008-01-11 16:58 by Nashev, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (15)
msg59720 - (view) Author: Nashev (Nashev) Date: 2008-01-11 16:58
In most platform-depended applications hot keys are working by the
specified keys on a keyboard, independent of a current keyboard layout.
Not by the specified char. 

Some application menus is displaying keyboard shortcut localized to main
layout for current language. But still working in any layout of keyboard
currently selected.

IDLE is not. :(

Can any one do something with it unpleasant situation?
msg59722 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-11 17:26
Not being familiar with localized keyboards, I don't understand your
question.  Can you provide some screen dumps of what you see and explain
what you expected to see?

PS. What OS?
msg59724 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-11 17:31
I *think* Nashev is talking about assigning hot keys by scan code rather
than by character code. 

E.g. on a German keyboard the 'z' and 'y' are switched and the 'z' key
is left to the 't' key. If a program assigns a hot key to 'z' by
character code than the user has to press the 'z' key which is a
different key on the German keyboard. However if a hot key is assigned
by scan code (not sure if it's the right term) than the hot key is still
assigned the physical key in the lower left corner.
msg59726 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-11 17:34
So what's a hot key?  Now I'm really confused.  I don't recall anything
using scan codes in IDLE, at least not for the memory shortcuts etc.
msg59729 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-01-11 17:45
Christian Heimes schrieb:
> Christian Heimes added the comment:
> 
> I *think* Nashev is talking about assigning hot keys by scan code rather
> than by character code. 
> 
> E.g. on a German keyboard the 'z' and 'y' are switched and the 'z' key
> is left to the 't' key. If a program assigns a hot key to 'z' by
> character code than the user has to press the 'z' key which is a
> different key on the German keyboard. However if a hot key is assigned
> by scan code (not sure if it's the right term) than the hot key is still
> assigned the physical key in the lower left corner.

On which platforms do hotkeys have that behavior? I've never seen it.
msg59731 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-11 17:50
> On which platforms do hotkeys have that behavior? I've never seen it.

Some computer games define hot keys by scan code rather than by
character.  I'm not sure if it's a good idea for IDLE but for games it
often makes sense.
msg59736 - (view) Author: Nashev (Nashev) Date: 2008-01-11 19:12
WOW, so active discussion!

OS - Windows & Mac OS X, both

Programs - most system and many others. 

Keyboard layouts - I mean mostly non latin (see
http://en.wikipedia.org/wiki/Keyboard_layout#Keyboard_layouts_for_non-Roman_alphabetic_scripts)

In case of russian keyboard layout i have in place of latin char 'x'
russian letter 'ч', and want to call <<Cut>> command by pressing this
hot key when keyboard really sent to application some like Ctrl+Ч too

In Windows we have messages WM_KeyDown and WM_KeyUp that send always key
index, stored as constants (defined in windows.h or messages.h) like
wk_return, wk_F1, etc. For letter keys, messages come with codes that
always equal to index of similar uppercase latin chars. for example,
first key code in middle row equal ord ('A') = 65. And in context of
russian layout this code translated to Cyrillic letter Ф and sent to
window with next message wm_char. Hot key handling based on WM_KeyDown,
nor WM_Char  

P.S.: Samples of localized showing of the hot keys in menu based on
interface language or current keyboard layout I can't find right now,
but i remember that I have this experience. This is feature not
necessary, because reading some like Ctrl+Ч near menu Cut is really
frustrating.
msg59742 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-11 19:58
IDLE is written using Tkinter, not native Windows UI programming APIs, I
don't know if the scan code is available in the keyboard events.

If you want something to happen on this, I suggest you try to create a
patch to IDLE yourself -- it's unlikely that any of the current
developers has the time to figure this out, given that we don't have
Russian keyboards nor Russian versions of Windows or Mac.
msg59746 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-01-11 20:40
IDLE lets you configure your own mappings without doing any programming.

From the menu, pick Options, Configure Idle and goto the Keys tab.
msg59749 - (view) Author: Nashev (Nashev) Date: 2008-01-11 21:06
Guido, I think now it is must be suggestion to TK team, in they's issue
tracker... 

Raymond, I know I can make try localized hot key mapping for my keyboard
layout for my self, but i think the best way is - help to make our
public libraries better for all. But any way, Thank You for try solve my
local problem.
msg62215 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2008-02-09 00:53
(sorry to be joining in late, but I just happened upon this...)

Nashev, if you configured your IDLE's keys to fit a Russian keyboard
layout, then you could post your config-keys.cfg file (from your .idlerc
directory) on the internet for others to enjoy. (this is the file where
user-configured key bindings are saved)

IMHO, specifically in the case of IDLE, binding to scan codes instead of
characters would be harmful, since it would be harder for users not
familiar with scan codes to understand and tweak.
msg67117 - (view) Author: Nashev (Nashev) Date: 2008-05-20 08:34
https://bugzilla.mozilla.org/show_bug.cgi?id=69230 - it is the same
bugreport for other program. It is contain many comments and explains :)
msg86386 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-04-23 23:46
That bug report is talking about gtk and modifiers affecting bindings
(in the first comments at least), or maybe it even talks about your
problem but it is so long that I would ask to include the relevant parts
here.

Nevertheless, after reading your comments I came to the conclusion that
doing what you want is very unlikely to happen. To bind something in Tk
you have to a specify a string like "<Control-x>", but to do what you
want, it would have to change to:

import Tkinter

def test(event):
    if event.keysym_num == ord('x') and event.state & 4:
        print "Ctrl-x!"

root = Tkinter.Tk()
root.bind('<KeyPress>', test)
root.mainloop()

Maybe you can test this and verify if it works like you wanted. But I
really don't see IDLE changing to work like that.
msg116864 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-19 11:23
From msg86386 "Nevertheless, after reading your comments I came to the conclusion that doing what you want is very unlikely to happen." so closing.
msg117259 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-09-24 03:07
it does seem that the consensus is that this is not a generally desirable feature.
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46127
2015-11-15 09:01:39THRlWiTisetnosy: + THRlWiTi
2010-09-24 03:07:25r.david.murraysetstatus: open -> closed
nosy: + r.david.murray, - BreamoreBoy
messages: + msg117259

resolution: rejected
stage: resolved
2010-09-19 11:23:26BreamoreBoysetnosy: + BreamoreBoy
messages: + msg116864
2009-04-23 23:46:49gpolosetversions: - Python 2.5
nosy: + gpolo

messages: + msg86386

components: + IDLE, - Tkinter
type: enhancement
2008-05-20 08:34:52Nashevsetmessages: + msg67117
2008-02-09 00:53:35taleinatsetnosy: + taleinat
messages: + msg62215
2008-01-23 22:30:44kbksetcomponents: - IDLE
2008-01-14 00:28:35kbksetnosy: + kbk
2008-01-11 21:06:28Nashevsetmessages: + msg59749
2008-01-11 20:40:58rhettingersetnosy: + rhettinger
messages: + msg59746
2008-01-11 19:58:44gvanrossumsetmessages: + msg59742
2008-01-11 19:12:25Nashevsetmessages: + msg59736
2008-01-11 17:50:51christian.heimessetmessages: + msg59731
2008-01-11 17:45:42georg.brandlsetnosy: + georg.brandl
messages: + msg59729
2008-01-11 17:34:36gvanrossumsetmessages: + msg59726
2008-01-11 17:31:16christian.heimessetnosy: + christian.heimes
messages: + msg59724
2008-01-11 17:26:20gvanrossumsetpriority: low
nosy: + gvanrossum
messages: + msg59722
2008-01-11 16:58:17Nashevcreate