Skip to main content

Best way for simulating keyboard input with javascript and miro web SDK?

  • October 31, 2025
  • 1 reply
  • 16 views

Forum|alt.badge.img

I’m working on integrating miro whiteboard in an VR application on Quest 3 device with an in-app web browser. Unfortunately clicking input fields in the whiteboard won’t make the system keyboard show up, but the browser plugin I’m using allows executing arbitary javascript on the page.

Currently I’m editing the content in the #canvas-focus-holder>p element when pressing keys on an virtual keyboard, but it doesn’t work well with the styles. Then I noticed miro web SDK, is there a way to better simulate keyboard input and edit elements on board correspondly with SDK?

1 reply

Horea Porutiu
Mironeer
Forum|alt.badge.img+1

Hey ​@Zihao Fu 

What about something like this approach: 

 

Use the Miro Web SDK to programmatically update the content of the text widget itself.

Instead of trying to "type" into the widget, your app could:

  1. Capture the text from your virtual keyboard.

  2. Identify the target text widget on the board (e.g., by getting the user's current selection).

  3. Update the widget's content property with the new text.

  4. Call the sync() method on the widget to apply the changes.

 

Example JavaScript (using Miro Web SDK v2)

 

Here is a code example of how you could get the currently selected text widget and update its content with input from your virtual keyboard.

// This function would be called when your VR user presses a key
// or submits text from their virtual keyboard.
async function updateSelectedText(newText) {

// 1. Get the currently selected items on the board
let selectedItems = await miro.board.getSelection();

// 2. Filter for the first selected text widget
let textItem = selectedItems.find(item => item.type === 'text');

if (textItem) {
// 3. Update the 'content' property of the local object.
// You can append, replace, or modify the text here.
// This example replaces the entire content.
textItem.content = newText;

// 4. Sync the changes back to the Miro board.
// This pushes the local update to the board for all users.
await textItem.sync();

console.log('Text widget updated successfully.');
} else {
console.log('No text widget is selected.');
}
}

// Example usage:
// Assume your VR keyboard just submitted "Hello World"
// updateSelectedText('Hello World');

// To append text, you would modify step 3:
// textItem.content = textItem.content + "a"; // Appends the letter 'a'