supermedium / aframe-super-keyboard

:musical_keyboard: Simple, functional, and fully customizable keyboard for A-Frame.
https://supermedium.com/aframe-super-keyboard
MIT License
127 stars 31 forks source link

How can I get the text when Enter pressed? #18

Open javipagan opened 4 years ago

DaryllConway commented 4 years ago

I also can't work this out, seems like some functional documentation would really help out here

feiss commented 4 years ago

Yes, you are alright, the documentation should help more. Meanwhile:

You have the superkeyboardinputevent. So:

  <script>
      AFRAME.registerComponent('my_keyboard_controller', {
        init: function(){
          this.el.addEventListener('superkeyboardinput', function(event){
            alert(event.value); // the text
          });
        }
      });
    </script>
...
<a-entity id="keyboard" super-keyboard my_keyboard-controller></a-entity>

sorry, I'm typing without trying, but this is how it should look like 🤞

kylebakerio commented 3 years ago

I have a semi-functional one up in my app, and am trying to get the input out of it. I tried just adding

window.addEventListener('superkeyboardchange', () => {
            console.log(arguments)
        })

and got nothing... same for input and dismiss. :/ will keep digging.

kylebakerio commented 3 years ago

for the record,

window.addEventListener('superkeyboardchange', function(event){
            console.log(event.detail.value); // the text
          });

works in the demo to get each keypress (and 'input' on enter, and I presume 'dismiss' on exit as in docs).

But those events are not firing for the keyboard when in my app... :(

kylebakerio commented 3 years ago

looking through the source I get downloaded to my site when I use the source recommended in the readme, I see that the only possible 'emit' values are 'keyboard-accepted' and 'keyboard-dismiss', which do not line up with what's in the docs, and do not give me the values input. Not sure if I have an older version or newer version, will try just downloading the dist file itself.

kylebakerio commented 3 years ago

Yup, that fixed it. Problem is following the README.

kylebakerio commented 3 years ago

README is using v 1.0, latest in dist is 2.1. will pull request readme to update.

andreeapav09 commented 3 years ago

Putting 2.1 makes it even worse for me, with this when I click on keyboards I don't even see input value now; did you find this problem?

andreeapav09 commented 3 years ago

I found the problem: I used hand-controls and it works only with laser-controls.