Git Product home page Git Product logo

Comments (18)

tehChromic avatar tehChromic commented on August 28, 2024 1

Francisco,

I see. What you are saying is that physical keyboard maps to the virtual key value, where I am looking for keys to map to virtual key position or index. The use case is a language learning application, and the idea is that the user can get used to typing their querty keyboard and have the virtual keyboard act as a kind of visual superimposition, so that the student can get physical sensation of typing the the Arabic word.

So I suspected I would have to do some mapping of physical keys to virtual keyboard and it sounds like that is what you are saying too. My question is, given that I've built event handlers into my script for physical keyboard interaction, what method can I use to highlight and/or trigger click events on virtual keys so I can set-up my mapping? I read through the docs but I don't see a way to do it outlined there.

Thanks and beautiful keyboard!!!

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024 1

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024 1

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

Hello @tehChromic,

It's hard to debug your specific issue without a reproducible example. If you could visit the demos page, edit one of the demos as to show the issue and share the link, then I'd definitely take a look.

Also, one way to check if physicalKeyboardHighlight is globally broken for your OS/Browser is to try out the following demo:

https://franciscohodge.com/projects/simple-keyboard/demo-showcase/full-keyboard/

If the keys are not highlighting for you in that page, then it's definitely is a bug to be investigated.

I'll close the ticket for now and reopen it once you provide the repro as described above.

Regards,
Francisco Hodge

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024

Thanks for prompt reply and direction Francisco!

I've dug in and discovered that my physical keyboard words as expected in the demo. However I've found that using 'arabic' layout causes the issue - the physical keyboard produces no response in the simplekeyboard and the input produces english letters.

Here is a Codepen: https://codesandbox.io/s/simplekeyboardjsdemos-trd8b

Here are the only pieces of code I've changed from the demo:


    let KeyboardLayouts = window.SimpleKeyboardLayouts.default;

    /**
    * Available layouts
    * https://github.com/hodgef/simple-keyboard-layouts/tree/master/src/lib/layouts
    */
    let layout = new KeyboardLayouts().get("arabic");
    // ...

    let keyboard = new Keyboard(".simple-keyboard-main", 
        Object.assign({}, commonKeyboardOptions, { layout: layout })
    )

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

Hello @tehChromic,

Thanks for the follow up, although I'm a bit unsure of what you're trying to achieve.

If you have a QWERTY physical keyboard and simple-keyboard set up with an Arabic layout, then physicalKeyboardHighlight won't highlight any Arabic keys in simple-keyboard.

For instance, when you hit the "q" key in your physical keyboard, no key will be highlighted in simple-keyboard as the key "q" won't exist in the Arabic simple-keyboard layout.

Regards,
Francisco Hodge

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

@tehChromic,

Thank you for the clarification, I understand now :)

I think this would have to be done through custom highlighting. I'll try something out and report back shortly.

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

Hello @tehChromic,

Here's a very rough attempt:

https://codesandbox.io/s/github/simple-keyboard/simple-keyboard-layouts-select-button-by-index-mapping/tree/master/

It basically grabs the position of the pressed button (within a qwerty layout) then goes and highlights the button at that position in simple-keyboard.

If you take this as a base, just know that it's a rough/incomplete idea and you'd have to improve it to fit your needs. Hope it helps though!

Regards,
Francisco Hodge

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

Hello @tehChromic,

Here's an improved version of my example, using the layouts from simple-keyboard-layouts and set up as a simple-keyboard module.

https://codesandbox.io/s/github/simple-keyboard/simple-keyboard-layouts-key-mapping-module-sample/tree/master/

Edit (>2.24.1 version):
https://codesandbox.io/s/simple-keyboard-layouts-demo-npm-4s4uv

Hope that helps!

Regards,
Francisco Hodge

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

Hello @tehChromic,

Thanks! Mappings in shift seem to be working. You basically have to hold down shift then press the desired button. The example is a bit barebones and quickly put together though, so it won't cover all bases (e.g.: There will be bugs). I hope however that you can take that and turn it into how you want it to work.

Regards,
Francisco Hodge

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

Indeed this releasing shift behavior would need to be made custom. This and some other custom approaches are explored in this test sandbox.

Regards,
Francisco Hodge

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

That is something that totally flew under my radar, thanks for bringing it up! I'll ship this asap and update this ticket.

Thanks,
Francisco Hodge

from simple-keyboard.

hodgef avatar hodgef commented on August 28, 2024

Hey @tehChromic,

The method destroy is now available as of version 2.22.0:
https://github.com/hodgef/simple-keyboard/releases/tag/2.22.0

Regards,
Francisco Hodge

from simple-keyboard.

tehChromic avatar tehChromic commented on August 28, 2024

from simple-keyboard.

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.