[PyQt] KeyPress events and numerical keys

Jorge Tornero jtorlistas at gmail.com
Wed Nov 13 07:14:26 GMT 2013


Hi all,

Well, I've coded a small application called TheKaunter,

https://github.com/jtornero/theKaunter/blob/master/source/theKaunter.py

Where I have a keyPressEvent function inside the main class
cellCounter(QWidget)  where keypressed are processed. I use
keyPressEvent.modifiers() to make possible to use the same key for
different purposes, say a key alone increases a counter while the same key
pressed altogether with shitf/control makes another thing.

The problem comes with numerical keys, because with shift+key the
correspondant symbol is generated (for instance, in a Spanish keyboard %
symbol is generated with shift+5) and the program is not able to process it
correctly because it receives the '%' key instead of 5 key plus modifier,
as happens with letter keys where, despite the fact about modifier key
pressed or not, you always receive a single key value (Capital letters in
this case).

In keyPressEvent() I check the key against a list of configuraed keys to
trigger one or another action. When you push a numerical key+shift, since
you receive the symbol and the modifier (not the number plus the modifier,
which is the defined key binding) the correspondant action can't be
triggered.

Any suggestions to override this?

Thank you very much

Jtornero
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20131113/2e5e6e08/attachment.html>


More information about the PyQt mailing list