On EVT_CHAR GetKeyCode() doesn't return 1

Hello, quoting the docs from
http://www.wxpython.org/docs/api/wx.KeyEvent-class.html

"[...] Another kind of translation is done when the control key is
pressed: for example, for CTRL-A key press the key down event still
carries the same key code 'A' as usual but the char event will have key
code of 1, the ASCII value of this key combination."

so I would expect to get the key code 1 for the CTRL-a combination, but
it doesn't, it returns 97 instead, the same as 'a'.
Am I missing something or it's a real bug?
(I'm using wxPython 2.6.1.1pre on Ubuntu)

Sounds as if you're using EVT_KEY_DOWN. Try using EVT_CHAR.

Phil Mayes

···

At 10:12 AM 5/14/2006, you wrote:

Hello, quoting the docs from
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

"[...] Another kind of translation is done when the control key is
pressed: for example, for CTRL-A key press the key down event still
carries the same key code 'A' as usual but the char event will have key
code of 1, the ASCII value of this key combination."

so I would expect to get the key code 1 for the CTRL-a combination, but
it doesn't, it returns 97 instead, the same as 'a'.
Am I missing something or it's a real bug?
(I'm using wxPython 2.6.1.1pre on Ubuntu)

I'm using EVT_CHAR in my application, but you can easily verify it
running KeyEvents.py included in the wxPython demo.

···

On Sun, 2006-05-14 at 10:17 -0700, Phil Mayes wrote:

At 10:12 AM 5/14/2006, you wrote:

>Hello, quoting the docs from
>wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
>
>"[...] Another kind of translation is done when the control key is
>pressed: for example, for CTRL-A key press the key down event still
>carries the same key code 'A' as usual but the char event will have key
>code of 1, the ASCII value of this key combination."
>
>so I would expect to get the key code 1 for the CTRL-a combination, but
>it doesn't, it returns 97 instead, the same as 'a'.
>Am I missing something or it's a real bug?
>(I'm using wxPython 2.6.1.1pre on Ubuntu)

Sounds as if you're using EVT_KEY_DOWN. Try using EVT_CHAR.

Here's a screenshot of KeyEvents.py when Ctrl-A is pressed; as you can see, it works for me. If you're seeing 97 where I see 1, it sounds like a real bug. I'm running Windows XP, Python 2.3.5 and wxPython 2.6.2.1.

Phil

keyevents.png

···

At 10:26 AM 5/14/2006, you wrote:

On Sun, 2006-05-14 at 10:17 -0700, Phil Mayes wrote:
> At 10:12 AM 5/14/2006, you wrote:
>
> >Hello, quoting the docs from
> >wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
> >
> >"[...] Another kind of translation is done when the control key is
> >pressed: for example, for CTRL-A key press the key down event still
> >carries the same key code 'A' as usual but the char event will have key
> >code of 1, the ASCII value of this key combination."
> >
> >so I would expect to get the key code 1 for the CTRL-a combination, but
> >it doesn't, it returns 97 instead, the same as 'a'.
> >Am I missing something or it's a real bug?
> >(I'm using wxPython 2.6.1.1pre on Ubuntu)
>
> Sounds as if you're using EVT_KEY_DOWN. Try using EVT_CHAR.

I'm using EVT_CHAR in my application, but you can easily verify it
running KeyEvents.py included in the wxPython demo.

Here's my screenshot.
Maybe it's a bug on the Linux platform only, can anyone reproduce this?

···

On Sun, 2006-05-14 at 11:35 -0700, Phil Mayes wrote:

At 10:26 AM 5/14/2006, you wrote:
Here's a screenshot of KeyEvents.py when Ctrl-A is pressed; as you can see,
it works for me. If you're seeing 97 where I see 1, it sounds like a real
bug. I'm running Windows XP, Python 2.3.5 and wxPython 2.6.2.1.

Lorenzo Allegrucci wrote:

···

On Sun, 2006-05-14 at 10:17 -0700, Phil Mayes wrote:

At 10:12 AM 5/14/2006, you wrote:

Hello, quoting the docs from
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

"[...] Another kind of translation is done when the control key is
pressed: for example, for CTRL-A key press the key down event still
carries the same key code 'A' as usual but the char event will have key
code of 1, the ASCII value of this key combination."

so I would expect to get the key code 1 for the CTRL-a combination, but
it doesn't, it returns 97 instead, the same as 'a'.
Am I missing something or it's a real bug?
(I'm using wxPython 2.6.1.1pre on Ubuntu)

Sounds as if you're using EVT_KEY_DOWN. Try using EVT_CHAR.

I'm using EVT_CHAR in my application, but you can easily verify it
running KeyEvents.py included in the wxPython demo.

This has been fixed in wxGTK. Please try a current version.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dumnn wrote:

Lorenzo Allegrucci wrote:
>>
>>> Hello, quoting the docs from
>>> wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
>>>
>>> "[...] Another kind of translation is done when the control key is
>>> pressed: for example, for CTRL-A key press the key down
event still
>>> carries the same key code 'A' as usual but the char event
will have
>>> key code of 1, the ASCII value of this key combination."
>>>
>>> so I would expect to get the key code 1 for the CTRL-a
combination,
>>> but it doesn't, it returns 97 instead, the same as 'a'.
>>> Am I missing something or it's a real bug?
>>> (I'm using wxPython 2.6.1.1pre on Ubuntu)
>> Sounds as if you're using EVT_KEY_DOWN. Try using EVT_CHAR.
>
> I'm using EVT_CHAR in my application, but you can easily verify it
> running KeyEvents.py included in the wxPython demo.

This has been fixed in wxGTK. Please try a current version.

I tried it on 2.6.3.2 on FC5. I found that it works if CAPS-LOCK is off, but
it returns 65 if CAPS-LOCK is on.

MSW correctly returns 1 in both cases.

Below is the screen shot. It is in text form - I could not figure out how to
save it as an image and transfer it to my MSW machine - but it is a genuine
copy-and-paste.

Frank Millman

Event Type Key Name Key Code Modifiers Unicode
RawKeyCode RawKeyFlags
KeyDown WXK_CONTROL 308 ---M 308 65507 0
KeyDown "A" 65 C--M 65 97 0
Char Ctrl-A 1 C--M 1 97 0
KeyUp "A" 65 C--M 65 97 0
KeyUp WXK_CONTROL 308 C--M 308 65507 0
KeyDown WXK_CAPITAL 311 ---M 311 65509 0
KeyUp WXK_CAPITAL 311 ---M 311 65509 0
KeyDown WXK_CONTROL 308 ---M 308 65507 0
KeyDown "A" 65 C--M 65 65 0
Char "A" 65 C--M 65 65 0
KeyUp "A" 65 C--M 65 65 0
KeyUp WXK_CONTROL 308 C--M 308 65507 0

I confirm the bug has been fixed in wxPython-2.6.3.2, thank you and
sorry for the noise.

···

On Sun, 2006-05-14 at 13:05 -0700, Robin Dunn wrote:

Lorenzo Allegrucci wrote:
> On Sun, 2006-05-14 at 10:17 -0700, Phil Mayes wrote:
>> At 10:12 AM 5/14/2006, you wrote:
>>
>>> Hello, quoting the docs from
>>> wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
>>>
>>> "[...] Another kind of translation is done when the control key is
>>> pressed: for example, for CTRL-A key press the key down event still
>>> carries the same key code 'A' as usual but the char event will have key
>>> code of 1, the ASCII value of this key combination."
>>>
>>> so I would expect to get the key code 1 for the CTRL-a combination, but
>>> it doesn't, it returns 97 instead, the same as 'a'.
>>> Am I missing something or it's a real bug?
>>> (I'm using wxPython 2.6.1.1pre on Ubuntu)
>> Sounds as if you're using EVT_KEY_DOWN. Try using EVT_CHAR.
>
> I'm using EVT_CHAR in my application, but you can easily verify it
> running KeyEvents.py included in the wxPython demo.

This has been fixed in wxGTK. Please try a current version.

Frank Millman wrote:

I tried it on 2.6.3.2 on FC5. I found that it works if CAPS-LOCK is off, but
it returns 65 if CAPS-LOCK is on.

Thanks, I'll get that fixed.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!