skol-pro / ion-digit-keyboard-v2

A digital keyboard plugin to use in Ionic 2 applications.
MIT License
94 stars 40 forks source link

Key events not working #2

Closed ssliman closed 7 years ago

ssliman commented 7 years ago

Hi, thanks for the beautiful keyboard.

I got one issue the events don't work for me. I cloned your project and tested it there. It doesn't log the key inputs.

for example this function

numberClick(key: number) { console.log('From event: ', key); }

Am i missing something? I followed the docs from top to bottom.

Thanks in advance!

skol-pro commented 7 years ago

Hi sliman180 !

Thank you, hope the documentation is clear enough, pretty new.

The only reason I see where the event binding wouldn't work, is that you probably put the numberClick function in a separate component file ?

If that's the case and you need to listen to event, you'll need to use a subscriber :-)

IonDigitKeyboard.onClick.subscribe((key) => {
    console.log('From subscriber: ', key);
})
ssliman commented 7 years ago

I cloned your project as a demo. The key event doesn't fire. I didn't change any code in your project. Can you test it when you have time?

Thanks!

skol-pro commented 7 years ago

Oh ok sorry. I did it before my last answer actually. It does work, that's why I was wondering. Any error in the console ?

ssliman commented 7 years ago

Nope, no errors in the console. I'll figure it out somehow. Thanks for your time!

mohamdio commented 7 years ago

Hi, thanks for this plugin.. i have the same issue this events don't fire numberClick or buttonClick, i tested that on this repo ! ?

regards

mohamdio commented 7 years ago

Hi, i think this events don't fire when testing on browser enough because this event [ (touchend) ] in template [ ion-digit-keyboard.html ] don't work and when changed it to [ (click) ] i can now listen to output events, it's strange because this (touchend) event should work on browser when develop the app touchend

regards

skol-pro commented 7 years ago

Hi mohamdio !

You're right, haven't thought about it since I'm using the Chrome Mobile Device Mode 99% of the time, and indeed touchend doesn't work in Normal Mode. It seems there is no way to detect it using javascript, so I won't be able to log something to developers...

Regarding the event it-self, I recommend you to keep touchend, the click event is damn slow on mobile devices.

mohamdio commented 7 years ago

@skol-pro Sure i will back to (touchend) event, so everything working fine now .. thank you 👍

ssliman commented 7 years ago

@skol-pro @mohamdio Is it possible to use the (tap)event from ionic 2? Or combining the directive tappable with (click) ? Is that a good aproach?

regards

skol-pro commented 7 years ago

@sliman180 Well, if I'm right, the tap event could work, however, the physical event must be a real tap, that means that if the user touch the screen for more than 300ms or something, it won't call anything. Matter of taste, but from my experience, the touchend event was the best, actually I made it to act like the iOS locked screen keyboard.

The click event must definitely be avoided on mobiles.

For the keyboard plugin, I could create a directive that check if we're on mobile or not, and/or add a option parameter for the event to be used.

ssliman commented 7 years ago

@skol-pro Yeah, that's true, now I understand why you use it.. You have a point there. It could be nice to have that directive. I appreciate your awesome work! 👍

skol-pro commented 7 years ago

@sliman180 He he, made with love and for fun :-) I'll see for the directive asap 👍

sneko commented 7 years ago

Hi @skol-pro ! Any news about implementing a mix of click/touchend depending on the platform? Thanks :)