I have a Custom Entry Control (ExtendedEntryCell)
in Xamarin Forms and want to detect if the user pressed "Return" on the keyboard. The custom control looks like this.
public class ExtendedEntryCell : Entry
{
public event EventHandler<EventArgs> KeyPressed;
public void SendKeyPressed(object sender, EventArgs e)
{
KeyPressed?.Invoke(sender, e);
}
}
For Windows Phone I created a Custom Renderer
based on this (External Link) example.
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control == null)
return;
Control.KeyDown -= Control_KeyDown;
Control.KeyDown += Control_KeyDown;
}
private void Control_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Enter)
{
(Element as ExtendedEntryCell).SendKeyPressed(Element, new EventArgs());
}
}
Is there a similar solution for iOS in Xamarin Forms?