Hid keyboard - message events

Sir, i am developting a ble keyboard hardware for my Mobile.

My Mobile connects to this ble keyboard hardware and i have a HID device.

It´s working very nice, when i press a key on the ble keyboard hardware, for example A,B,C.., in can see them on APPINVENTOR APP if APPINVENTOR virtual keyboard is open on screen.

But imagine one case study where an APPINVENTOR APP screen not shows the virtual keyboard and you press a key on the ble keyboard hardware, in theory you will loose that key right ?

Well, i dont want to loose that key, i want that APPINVENTOR APP know about that key pressed and do something, being the main APP or not ?

Think about a Situation that the APPINVENTOR APP is running in background, you open any other APP and you press a sequence key A,A,A,B on ble keyboard hardware, your APPINVENTOR APP must to detect too that sequence.

I guess, that there is a option to capture the ANDROID O.S EVENTS, too see all that is travelling, something like this

About Messages and Message Queues - Win32 apps | Microsoft Docs

Do you undestand ?

I can send one of these multiples sequences! But the APPINVENTOR must to detect one, regardless of being the main app running

exports.MODIFY = {
CTRL : 0x01,
SHIFT : 0x02,
ALT : 0x04,
GUI : 0x08,
LEFT_CTRL : 0x01,
LEFT_SHIFT : 0x02,
LEFT_ALT : 0x04,
LEFT_GUI : 0x08,
RIGHT_CTRL : 0x10,
RIGHT_SHIFT : 0x20,
RIGHT_ALT : 0x40,
RIGHT_GUI : 0x80
};
exports.KEY = {
A : 4 ,
B : 5 ,
C : 6 ,
D : 7 ,
E : 8 ,
F : 9 ,
G : 10,
H : 11,
I : 12,
J : 13,
K : 14,
L : 15,
M : 16,
N : 17,
O : 18,
P : 19,
Q : 20,
R : 21,
S : 22,
T : 23,
U : 24,
V : 25,
W : 26,
X : 27,
Y : 28,
Z : 29,
1 : 30,
2 : 31,
3 : 32,
4 : 33,
5 : 34,
6 : 35,
7 : 36,
8 : 37,
9 : 38,
0 : 39,
ENTER : 40,
"\n" : 40,
ESC : 41,
BACKSPACE : 42,
"\t" : 43,
" " : 44,
"-" : 45,
"=" : 46,
"[" : 47,
"]" : 48,
"\" : 49,
NUMBER : 50,
";" : 51,
"'" : 52,
"~" : 53,
"," : 54,
"." : 55,
"/" : 56,
CAPS_LOCK : 57,
F1 : 58,
F2 : 59,
F3 : 60,
F4 : 61,
F5 : 62,
F6 : 63,
F7 : 64,
F8 : 65,
F9 : 66,
F10 : 67,
F11 : 68,
F12 : 69,
PRINTSCREEN : 70,
SCROLL_LOCK : 71,
PAUSE : 72,
INSERT : 73,
HOME : 74,
PAGE_UP : 75,
DELETE : 76,
END : 77,
PAGE_DOWN : 78,
RIGHT : 79,
LEFT : 80,
DOWN : 81,
UP : 82,
NUM_LOCK : 83,
PAD_SLASH : 84,
PAD_ASTERIX : 85,
PAD_MINUS : 86,
PAD_PLUS : 87,
PAD_ENTER : 88,
PAD_1 : 89,
PAD_2 : 90,
PAD_3 : 91,
PAD_4 : 92,
PAD_5 : 93,
PAD_6 : 94,
PAD_7 : 95,
PAD_8 : 96,
PAD_9 : 97,
PAD_0 : 98,
PAD_PERIOD : 99
};

Hi Miguel - an exciting project!

To achieve what you describe needs Android Background Services. App Inventor does not have built-in support for them but there is an extension that might suit your requirement. Search https://puravidaapps.com/extensions.php

Hi, i didnt find there where to monitor the HID keyboard events :frowning:

That is the part that the Extension may be able to cover - if it can, there surely is no need to capture Android OS Events (something that is most likely prevented by a Google security measure).

https://community.kodular.io/t/backgroundtasks-extension-paid/73771

Actually Miguel, is your keyboard intended to work with all relevant Apps on the phone (HID) or just your App Inventor App? I ask because you can stream text to your App via BLE and update a TextBox. You could also send a command to back-delete.

Otherwise, perhaps you should be looking at coupling your BLE Keyboard with the device rather than a specific App, a common place solution.