1

I need to find what key the user pressed on a keyboard using xamarin.forms, ideally inside an AbsoluteLayout. I've come up with a few ways myself, but can't get any of them working.

As there isn't an event for this on the AbsoluteLayout control, i tried a little cheat, which was putting an entry field (textbox) on the screen, but hiding it above, so it can't be seen and using the result from that, but it loses focus when someone presses the screen or a button on the screen. so i tried adding an event to each button which refocuses the textbox once i've handled the press and this seemed ok at first, however, if they press anywhere else on the screen, it also loses focus.

I also tried adding a TapGestureRecognizer to the screen, and focusing the button when they press anywhere on the screen, however, there were 2 issues with this, the first being that it appears to only fire when something inside it is touched, and secondly, when i call the focus method for the second time (if they click the screen twice) it un-focuses the entry field, even if i check "isfocused" first (think this is a bug).

I'm only concerned about windows 8 and android apps so far. iOS may come later, but for now im just trying to get it working for these OS's. so maybe i could code it in the windows and android projects (inside my shared project solution), however, i have absolutely no idea where to even begin doing that. I mean, if this is the best way, how can i pass my AbsoluteLayout to the windows project and get it to know what it is, and convert it into a control which i can then add the event to.

Any help or advice, or ideas would be much appreciated. I cant find anything in NuGet which will help me with this. Any ideas?

Many thanks James

James Kirk
  • 19
  • 3
  • What problem you are facing with images with tapGesture on em ? you can define styleId of image obj to know which image was pressed ? – Saket Kumar May 19 '16 at 13:35
  • the issue is not with clicking, it's that i need to know about the "Keyboard" button press events. i dont need to know which image was pressed. – James Kirk May 19 '16 at 13:38
  • you need to know when the key on keyboard is pressed right ? . so when u add a tap gesture on it , u can fire an event based on key press . – Saket Kumar May 19 '16 at 13:51
  • how would i do that? the TapGesture doesn't contain anything for key presses, and neither does the control. – James Kirk May 19 '16 at 14:03
  • Did you ever figure this out? I want to do a similar thing. – Jay Jun 01 '18 at 16:25
  • this was a while ago, but if i remember rightly i ended up using a third party plugin for this. there's like swipe gesture plugins and touch plugins. (nuget) – James Kirk Apr 15 '19 at 08:18

0 Answers0