'Delphi Android: Intercept keys from hardware keyboard
Is it posible in Delphi Android to intercept keyboard presses from hardware keyboard (HID device) attached to device? I can detect if is HID Device present.
function TForm1.AttachedHIDDevice: Boolean;
var
i: Jiterator;
JavaObject: JObject;
DeviceList: JHashMap;
USBDevice: JUSBDevice;
UsbManager: JUSBManager;
begin
//Device discovery
Result := False;
//Get pointer to UsbManager
JavaObject := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.USB_SERVICE);
UsbManager := TJUsbManager.Wrap((JavaObject as ILocalObject).GetObjectID);
if not Assigned(UsbManager) then Exit;
//Get a list of connected devices
DeviceList := UsbManager.getDeviceList;
i := DeviceList.values.iterator;
while i.hasNext do begin
USBDevice := TJUsbDevice.Wrap((i.next as ILocalObject).GetObjectID);
if (USBDevice.getInterfaceCount > 0) then
begin
Result := USBDevice.getInterface(0).getInterfaceClass = TJUsbConstantsUSB_CLASS_HID;
if Result then Break;
end;
end;
end;
I would like to intercept Key from external keyboard before it reaches TEdit or TForm while App is running. There is some "proposals" how to do it keyboard-input/commands but I could not find any Delphi example.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
