Skip to first unread message

Hardcore Kitty

unread,
Feb 4, 2018, 6:58:45 PM2/4/18
to MIT App Inventor Forum
Hello Everyone,

I have seen everywhere, but really unable to find how to simulate keypresses from 1 device to another over bluetooth,
I am able to send text messages over BT & even singlle characters but they are not acting as KEYPRESSES.

Can anyone help ?
Is it really possible to creatte an input device using App Inventor or is it out of bounds of features ? 

SteveJG

unread,
Feb 5, 2018, 6:59:37 PM2/5/18
to mitappinv...@googlegroups.com
What does a KEYPRESSES mean to you?    If you can capture single characters from a Bluetooth keyboard, you can simulate the event handling of 
many controls.

What I think you want to do is possibly press a Button and get a result. A Button, and many other App Inventor controls have EVENTS,
When you click on a Button, you elicit the Button Click event handler.


Events

Click()
User tapped and released the button.

It is possible to simulate this but not actually 'Press the Button."  It is also possible to 'press a button' by using the BTKB navigation buttons (PgUp/PgDn/Home/End (the arrows) )and then pressing the Enter key on the BTKB.

When your Bluetooth keyboard types a letter, and you capture that letter (you say you know how to do that) , you can turn that into an event handler.

In this example, the letter I capture from the BT is captured in a Clock component.


The colored blocks show an if statement.  If the letter captured is R, an Image Sprite is moved to the right on a Canvas; capturing a L results in moving the sprite to the left.

Similarly, one can use the conditional statement to elicit whatever blocks you might provide in a Button.Click event handler and others where there is an appropriate event.

I would answer this question "Is it really possible to creatte an input device using App Inventor or is it out of bounds of features ? " but I do not understand what you want to create.   Tell us more please.



Regards,
Steve







Hardcore Kitty

unread,
Feb 8, 2018, 2:00:13 PM2/8/18
to MIT App Inventor Forum
Hello Steve,

Thanks for your Reply.
What you have shown me below are only the characters which would work only as a phrase.
They don;t work on WEBVIEWER Component
How do I pass Left, Up, Right, Enter, Esc, Del etc.
Is it possible to simulate click on a specific coordinate on screen?
What i actually intend to do is this:
I have 2 Android devices which will be connected via bluetooth
  1. DISPLAY Screen (On which a webpage like youtube.com) will open
    It contains webviewer on the whole screen
  2. Keyboard Screen (through which i want to pass the Key events e.g. A space bar pauses the Youtube video)
    I want to have this keyboard's functionality like Spacebar, W,A,S,D etc to get simulated onto the webviewer whose Javascript of on Keydown events will yield me the result on the other Android Device.
I am able to pass on the messages between both the devices, but unable to interact with the WEBVIEWER component, & that's the reason I want this keyboard functionality. Please guide me with the steps.

SteveJG

unread,
Feb 8, 2018, 5:22:17 PM2/8/18
to MIT App Inventor Forum
I do not believe this is possible using a keyboard on a second device. There are no Methods one can interact with.on the WebViewer.


This CAN be done with a WebViewer using a real hardware Bluetooth Keyboard  https://groups.google.com/forum/#!category-topic/mitappinventortest/UDcX0doXg48  .  A Bluetooth keyboard can navigate a web page on a WebViewer; not well but I can using a hardware BTKB to traverse a web page..

A Bluetooth keyboard sends virtual key board esc codes  https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 .   How one would send the esc codes or characters with an Android virtual keyboard is anyone's guess. A primer for Java coders is here https://stackoverflow.com/questions/11768356/need-table-of-key-codes-for-android-and-presenter .  A jquery keyboard is here  https://www.sitepoint.com/4-jquery-screen-keyboards/  .  You might be able to get it to respond as a virtual BTKB.   How?   :))))

Have fun.

Reply all
Reply to author
Forward
0 new messages