However, I also have the problem that num pad numbers are presented differently e.g. when I press ‘1’ then ‘num_1’ is shown on the screen.
I tried to extend the code of jacanterbury by inserting the following line in the each frame part:
elif ‘num_’ in keys:
text.text = text.text.replace(‘num_’, ’ ')
Unfortunately, this does not work (I tried also several other combinations). Has anyone an idea what is wrong with this code?
What happens if you put a print statement inside that if gate? Does it print?
I suspect it might be that it’s looking for an item in keys whose value is in its entiretynum_, when what you want to know is whether num_ is in any string within keys. You can use this instead to ensure that behaviour:
elif any('num_' in key for key in keys): # if any key in keys contains 'num_'
…or, if you prefer, you could treat keys as one long string:
Thank you very much for your reply!
I implemented your code, but it worked only partly when I put it as a separate if statement.
if any(‘num_’ in key for key in keys):
text.text = text.text.replace(‘num_’, ‘’)
When I now use the numpad then I see the actual pressed number as “num_” e.g. “num_1” but the strange thing is that when I press another number e.g. “num_2” on the num pad then the first number “num_1” is converted to “1”. On the screen is see the following “1num_2”. This continues further e.g. “1234num_5”. Hope my outline is understandable. Do you have an idea of how to convert also the actual input?