Giter Site home page Giter Site logo

Multinational Keyboard Support about spacesvr HOT 3 CLOSED

musehq avatar musehq commented on May 17, 2024
Multinational Keyboard Support

from spacesvr.

Comments (3)

alex-shortt avatar alex-shortt commented on May 17, 2024

this might be the answer: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code

from spacesvr.

AlaricBaraou avatar AlaricBaraou commented on May 17, 2024

Just tried this example http://output.jsbin.com/noyudo/5
From this article https://hacks.mozilla.org/2017/03/internationalize-your-keyboard-controls/

The main issue remains, for most case we can't detect the layout in order to display the right controls on page load.

We could update the WASD/ZQSD/... indicator when the user press whatever key that correspond to code='KeyW'

There is also this experimental Keyboard API that could allow us to detect the Keyboard layout in some browsers.
https://developer.mozilla.org/en-US/docs/Web/API/Keyboard_API

if (navigator.keyboard) {
  var keyboard = navigator.keyboard;
  keyboard.getLayoutMap()
  .then(keyboardLayoutMap => {
    var upKey = keyboardLayoutMap.get('KeyW');
    window.alert('Press ' + upKey + ' to move up.');
  });
} else {
  // Do something else.
}

from spacesvr.

alex-shortt avatar alex-shortt commented on May 17, 2024

found this, seems like event.code is the right way?

mozilla/hubs#2397
mozilla/hubs@c544888

you probably can't explicitly detect which keyboard the user is using but just look for the keys in the right position at the very least

from spacesvr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.