
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
threejs-vr-keyboard
Advanced tools
A keyboard input based on THREE.js for virtual reality experiences or just as an alternative to the standard on-screen keyboard on touch devices.
Include THREE.js library and VRKeyboard:
<script src="libs/three.min.js"></script>
<script src="js/VRKeyboard.js"></script>
Create a basic 3D scene:
<script>
var container;
var camera;
var scene, renderer;
var vrKeyboard;
function init(element){
container= document.getElementById(element);
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 20000);
scene = new THREE.Scene();
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
camera.position.set(0, 0, 1500);
camera.lookAt(new THREE.Vector3(0,0,0))
animate();
}
function animate(){
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
</script>
<body onload="init('container')">
<div id="container"></div>
</body>
Instantiate a VRKeyboard passing a reference to current scene, camera and renderer:
var vrKeyboard = new VRKeyboard(scene, camera, renderer)
Call the VRKeyboard update in the rendering loop:
function animate(){
vrKeyboard.update()
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
Listen for events:
vrKeyboard.addEventListener("keydown", function(e){
console.log("You pressed the: "+e.code+" key")
}
Supported events are:
Add and layout VRTextInput instances as necessary, for example:
var usernameTxt = new VRTextInput();
usernameTxt.width = 400;
usernameTxt.position.set(0,300,0);
var passwordTxt = new VRTextInput();
passwordTxt.width = 400
passwordTxt.position.set(0,220,0);
passwordTxt.displayAsPassword = true;
Register VRTextInput instances to the VRKeyboard:
vrKeyboard.addField(usernameTxt);
vrKeyboard.addField(passwordTxt);
Registered fields automatically receive focus when clicked.
To set focus programmatically assign it as target of the VRKeyboard:
vrKeyboard.target = usernameTxt;
Then type something and get the VRTextInput value, e.g.:
vrKeyboard.addEventListener("keydown", function(e){
if(e.code == Unicode.ENTER){
console.log(usernameTxt.value);
}
}
VRKeyboard exposes the following attributes for basic customization:
Example:
//Red key background with yellow labels and no rounded corners
vrKeyboard.keyColor="#D90000";
vrKeyboard.labelColor="#FFD24D";
vrKeyboard.borderColor="#FFD24D";
vrKeyboard.keyDownColor="#B20000";
vrKeyboard.labelDownColor="#FFBF00";
vrKeyboard.borderDownColor="#D90000";
vrKeyboard.borderRadius=0
VRTextInput styling woks similar:
//Red background with yellow text and no rounded corners
searchTxt.backgroundColor="#D90000";
searchTxt.textColor="#FFD24D"
searchTxt.borderColor="#FFD24D";
searchTxt.backgroundFocusColor="#B20000";
searchTxt.textFocusColor="#FFBF00"
searchTxt.borderFocusColor="#FF0000";
searchTxt.borderRadius=0
If you want to go more in depth on styling and customizing, have a look at the draw() and drawKey() methods.
FAQs
Unknown package
We found that threejs-vr-keyboard demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.