Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phystical Keyboard input for Arabic layout #90

Closed
tehChromic opened this issue May 29, 2019 · 18 comments
Closed

Phystical Keyboard input for Arabic layout #90

tehChromic opened this issue May 29, 2019 · 18 comments
Assignees
Labels
💥 Bug Something isn't working 📦 Use case A question regarding implementation
Milestone

Comments

@tehChromic
Copy link

Hi,
I am having an issue which is that I would like to be able to type on my physical keyboard and have the keys trigger click events on the virtual keyboard - this is for typing on an american keyboard and having the input field be in Arabic.

I've found the physicalKeyboardHighlight and actually it doesn't seem to highlight any of my letter keys (using Chrome on Linux). I've also found the physicalKeyboardInterface method, and used the initKeyboardListener, however this does not appear to do anything. I don't know if that's because there is an issue as described with highlights issue, or if I am using it wrong.

Thanks!!

@hodgef hodgef self-assigned this May 29, 2019
@hodgef
Copy link
Owner

hodgef commented May 29, 2019

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

@hodgef hodgef closed this as completed May 29, 2019
@hodgef hodgef added the 🕑 Waiting for OP This issue requires more information as requested by the maintainer. label May 29, 2019
@tehChromic
Copy link
Author

tehChromic commented May 29, 2019

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 })
    )

@hodgef
Copy link
Owner

hodgef commented May 29, 2019

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

@tehChromic
Copy link
Author

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!!!

@hodgef
Copy link
Owner

hodgef commented May 29, 2019

@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.

@hodgef hodgef reopened this May 29, 2019
@hodgef hodgef added 🔍 Investigating Investigating what's causing the issue and removed 🕑 Waiting for OP This issue requires more information as requested by the maintainer. labels May 29, 2019
@hodgef
Copy link
Owner

hodgef commented May 29, 2019

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

@hodgef hodgef closed this as completed May 29, 2019
@hodgef hodgef added 📦 Use case A question regarding implementation and removed 🔍 Investigating Investigating what's causing the issue labels May 29, 2019
@tehChromic
Copy link
Author

tehChromic commented Jun 1, 2019 via email

@hodgef hodgef added the 📌 Follow up This ticket has been acknowledged. There may be a follow-up at a later time. label Jun 1, 2019
@hodgef hodgef reopened this Jun 1, 2019
@hodgef hodgef added 🔍 Investigating Investigating what's causing the issue and removed 📌 Follow up This ticket has been acknowledged. There may be a follow-up at a later time. labels Jun 1, 2019
@hodgef
Copy link
Owner

hodgef commented Jun 1, 2019

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

@hodgef hodgef closed this as completed Jun 1, 2019
@hodgef hodgef removed the 🔍 Investigating Investigating what's causing the issue label Jun 1, 2019
@tehChromic
Copy link
Author

tehChromic commented Jun 2, 2019 via email

@hodgef
Copy link
Owner

hodgef commented Jun 2, 2019

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

@tehChromic
Copy link
Author

tehChromic commented Jun 2, 2019 via email

@hodgef
Copy link
Owner

hodgef commented Jun 2, 2019

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

@tehChromic
Copy link
Author

tehChromic commented Jun 2, 2019 via email

@hodgef
Copy link
Owner

hodgef commented Jun 2, 2019

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

@hodgef hodgef reopened this Jun 2, 2019
@hodgef hodgef added the 💥 Bug Something isn't working label Jun 2, 2019
@hodgef hodgef added this to the 2.22.0 milestone Jun 2, 2019
@hodgef
Copy link
Owner

hodgef commented Jun 2, 2019

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

@hodgef hodgef closed this as completed Jun 2, 2019
@tehChromic
Copy link
Author

tehChromic commented Jun 2, 2019 via email

@tehChromic
Copy link
Author

tehChromic commented Jun 2, 2019 via email

@tehChromic
Copy link
Author

tehChromic commented Jun 2, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💥 Bug Something isn't working 📦 Use case A question regarding implementation
Projects
None yet
Development

No branches or pull requests

2 participants