Pygame程序,可以获得键盘输入带帽 [英] Pygame program that can get keyboard input with caps

查看:699
本文介绍了Pygame程序,可以获得键盘输入带帽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要文本输入的Pygame程序。它的方式是获得键盘输入,当按下一个键时,它呈现该键,所以它被添加到屏幕。本质上它像一个文本字段。问题是,当你握住shift,它不做任何事情。我意识到这是因为程序忽略移位输入,而是写入文本,如果它的数字是在128以下。我想到设置一个变量,当shift按下,然后大写,如果它是真的,但字符串大小写只在字母,而不是东西像数字或分号。是否可能有一个数字可以添加到ASCII数字键入修改它,如果shift按下,或其他吗?

编辑:

基本上,我只想知道是否有一个数字添加到ascii字符,以使它看起来像他们输入shift按住。

I have a Pygame program that needs text input. The way it does this is to get keyboard input and when a key is pressed it renders that key so it is added to the screen. Essentially it acts like a text field. The problem is, when you hold shift it doesn't do anything. I realize this is because the program ignores shift input and instead writes the text if it's number is under 128. I have thought of setting a variable when shift is pressed then capitalizing if it was true, but string capitalization only woks on letters, not things like numbers or semicolons. Is there maybe a number I can add to the ASCII number typed to modify it if shift is pressed, or something else?

Essentially, I just want to know if there is a number to add to ascii characters to make it seem like they were typed with shift held down. After reading over my original question it seemed slightly obscure.

推荐答案

我可以使用'event.unicode'属性来获取值的键。

I can use the 'event.unicode' attribute to get the value of the key typed.

这篇关于Pygame程序,可以获得键盘输入带帽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆