hodgef/react-simple-keyboard

onKeyPress and onChange not working

shhivv opened this issue · 3 comments

Hey,

So I have been trying to use this library and the onKeyPress prop doesn't seem to be present and onChange doesn't seem to be working.

This is my code

import Keyboard from "react-simple-keyboard";
import "react-simple-keyboard/build/css/index.css";
import "../styles/keyboard.css"

export default function LayoutKeyboard(){

    const layout =  [
        "q w e r t y u i o p {bksp}",
        "a s d f g h j k l",
        "z x c v b n m {enter}",
      ]

    return <Keyboard
            theme={"hg-theme-default myTheme1"}
            display={{
              '{bksp}' : '⌫',
              '{enter}': '✔'
            }}
            onChange={console.log}
            layout={{default: layout}}
         />
}

I am currently using version 3.4.83 on Brave and Windows 11

image

By not working, I mean that nothing is being logged to console.

Hello @ffaanngg,

Does this demo work for you?
https://codesandbox.io/s/fervent-dewdney-thrfti

TEST

If so there must be something wrong in your implementation, if you could share a reproducible example (such as a test git repo) that will help with the debugging.

Regards,
Francisco Hodge

Thanks for the quick reply. It appears to work now when I console.log through a callback.