[Gambas-user] Control + key combination detection Q
Jack
jscops at ...11...
Fri Oct 8 01:16:31 CEST 2010
richard terry a écrit :
> On Friday 08 October 2010 01:11:02 Jack wrote:
>> richard terry a écrit :
>>> >From the docs:
>>>
>>> If Key.Code = Key["R"] And If Key.Control Then
>>> Print "You hit CTRL+R"
>>> End If
>>>
>>> If my hands this does the following
>>> Key.code = 1677724
>>> Key["R"] = 82
>>> Key.control = true
>>>
>>> but I'm probably pressing ctrl + small r I guess:
>>>
>>> Clearly they don't match
>>>
>>> If I put on the capslock to ensure a capital R, results are similar.
>>> ie one long number, the small number.
>>>
>>>
>>> What could I be doing wrong?
>> Perhaps this code ?
>>
>> IF key.Control THEN
>> IF key.code = key["R"] THEN
>> Print "You hit CTRL+R"
>> End If
>
> Key.code = 1677724
> Key["R"] = 82
>
> As pointed out above this is the problem, should work according to the docs
> but returns different numbers
>
In my box. Key.control = 4129 and key["R"] = 82.
But as it is say in the doc, "Never compare the value of this property
with a numeric constant, because the key codes may depend on the
underlying toolkit.
Always use the constants defined in this class! "
More information about the User
mailing list