This guide will walk you through setting up kbdmouse-js in a new project.
- Node.js (version 14 or higher)
- npm (comes with Node.js)
mkdir kbdmouse-demo
cd kbdmouse-demo
npm init -ynpm install @devscholar/kbdmouse-jsCreate an index.html file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>KBDMouseJS Demo</title>
<link rel="stylesheet" href="@devscholar/kbdmouse-js/dist/kbdmouse-js.css">
</head>
<body>
<h1>KBDMouseJS Quick Start</h1>
<textarea id="demo-textarea" placeholder="Type here..." rows="4" style="width: 100%;"></textarea>
<p>The virtual keyboard will appear automatically when you focus on the textarea.</p>
<virtual-keyboard></virtual-keyboard>
<div id="target-area">
<p>Draw or drag here with touch (mobile)</p>
</div>
<script type="module">
import { VkMouse } from "@devscholar/kbdmouse-js";
document.addEventListener("DOMContentLoaded", function () {
let element = document.getElementById("target-area");
if (element) {
let vkMouse = new VkMouse(element);
console.log("Mouse polyfill initialized");
}
});
</script>
</body>
</html>We recommend using Vite as your development server:
npm install -D viteAdd a start script to your package.json:
{
"scripts": {
"start": "vite"
}
}Then start the development server:
npm run startNavigate to http://localhost:5173 (Vite default port).