如何在按键时识别Unicode键? [英] How to identify unicode keys on key press?

查看:101
本文介绍了如何在按键时识别Unicode键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用Unicode字符,我有几个文本字段,我想限制用户输入诸如:';

My application uses unicode characters and i have several text fields where i want to restrict user from inputing special characters like :'";

begin
    if not (Key in ['a'..'z','A'..'Z',' ','0'..'9',#13,#8]) then
        Key := #0;
    if Key = #13 then
        bOk.Click;
end;

因此,在这一点上,它允许用户添加空格并使用退格键进行擦除,当然还可以使用Enter键进行确认。

So at this point it lets user add spaces and use a backspace key to erase, and of course Enter key to comfirm.

我也想输入很少的Unicode字符
±,č,ė,į,š,ų,ū,ž
及其它们大写字母替代项,但只需将它们像这样添加到集合中即可。

There are few unicode characters i want to let being inputed also. ą, č, ė, į, š, ų, ū, ž and their uppercase alternatives, but just adding them to the set like so...

Key in ['a'..'z','A'..'Z',' ','0'..'9',#13,#8,'ą'..'ž','Ą'..'Ž']

...什么也不做,我仍然无法在文本字段中写这些符号。

... does nothing and i still can not write these symbols in the text field.

我想知道如何解决此问题,有没有办法判断是否按下了键

I would like to know, how to fix this problem. Is there a way to tell if the pressed key is the unicode character i'm looking for?

谢谢

推荐答案

如果您使用的是D2009或更高版本,则有一个名为 Character 的单元,其中包含诸如 IsLetterOrDigit IsLetter 等功能,这些都专门处理您的工作需要。

If you're on D2009 or later there's a unit named Character containing functions like IsLetterOrDigit, IsLetter, etc. all handling specifically what you need.

这篇关于如何在按键时识别Unicode键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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