Compartilhar via


InputDevice.GetKeyCodeForKeyLocation(Int32) Method

Definition

Gets the android.view.KeyEvent key code produced by the given location on a reference QWERTY keyboard layout.

[Android.Runtime.Register("getKeyCodeForKeyLocation", "(I)I", "", ApiSince=33)]
public int GetKeyCodeForKeyLocation (int locationKeyCode);
[<Android.Runtime.Register("getKeyCodeForKeyLocation", "(I)I", "", ApiSince=33)>]
member this.GetKeyCodeForKeyLocation : int -> int

Parameters

locationKeyCode
Int32

The location of a key specified as a key code on the QWERTY layout. This provides a consistent way of referring to the physical location of a key independently of the current keyboard layout. Also see the hypothetical keyboard provided by the W3C, which may be helpful for identifying the physical location of a key.

Returns

The key code produced by the key at the specified location, given the current keyboard layout. Returns KeyEvent#KEYCODE_UNKNOWN if the device does not specify InputDevice#SOURCE_KEYBOARD or the requested mapping cannot be determined.

Attributes

Remarks

Gets the android.view.KeyEvent key code produced by the given location on a reference QWERTY keyboard layout.

This API is useful for querying the physical location of keys that change the character produced based on the current locale and keyboard layout.

The following table provides a non-exhaustive list of examples: <table border="2" width="85%" align="center" cellpadding="5"> <thead> <tr><th>Active Keyboard Layout</th> <th>Input Parameter</th> <th>Return Value</th></tr> </thead>

<tbody> <tr> <td>French AZERTY</td> <td>{@link KeyEvent#KEYCODE_Q}</td> <td>{@link KeyEvent#KEYCODE_A}</td> </tr> <tr> <td>German QWERTZ</td> <td>{@link KeyEvent#KEYCODE_Y}</td> <td>{@link KeyEvent#KEYCODE_Z}</td> </tr> <tr> <td>US QWERTY</td> <td>{@link KeyEvent#KEYCODE_B}</td> <td>{@link KeyEvent#KEYCODE_B}</td> </tr> </tbody> </table>

Java documentation for android.view.InputDevice.getKeyCodeForKeyLocation(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to