Add InputEventKey.location to tell left from right

This adds a new enum `KeyLocation` and associated property
`InputEventKey.location`, which indicates the left/right location of key
events which may come from one of two physical keys, eg. Shift, Ctrl.

It also adds simulation of missing Shift KEYUP events for Windows.
When multiple Shifts are held down at the same time, Windows natively
only sends a KEYUP for the last one to be released.
This commit is contained in:
Mel Collins 2023-08-03 15:18:26 +02:00
parent 4b6ad34988
commit 8406e60522
35 changed files with 397 additions and 26 deletions

View file

@ -24,6 +24,12 @@
Returns a [String] representation of the event's [member keycode] and modifiers.
</description>
</method>
<method name="as_text_location" qualifiers="const">
<return type="String" />
<description>
Returns a [String] representation of the event's [member location]. This will be a blank string if the event is not specific to a location.
</description>
</method>
<method name="as_text_physical_keycode" qualifiers="const">
<return type="String" />
<description>
@ -77,6 +83,9 @@
+-----+ +-----+
[/codeblock]
</member>
<member name="location" type="int" setter="set_location" getter="get_location" enum="KeyLocation" default="0">
Represents the location of a key which has both left and right versions, such as [kbd]Shift[/kbd] or [kbd]Alt[/kbd].
</member>
<member name="physical_keycode" type="int" setter="set_physical_keycode" getter="get_physical_keycode" enum="Key" default="0">
Represents the physical location of a key on the 101/102-key US QWERTY keyboard, which corresponds to one of the [enum Key] constants.
To get a human-readable representation of the [InputEventKey], use [method OS.get_keycode_string] in combination with [method DisplayServer.keyboard_get_keycode_from_physical]: