Share via


SearchBox.FocusOnKeyboardInput Property

Definition

Gets or sets a value that determines whether a user can search by typing anywhere in the app.

public:
 property bool FocusOnKeyboardInput { bool get(); void set(bool value); };
bool FocusOnKeyboardInput();

void FocusOnKeyboardInput(bool value);
public bool FocusOnKeyboardInput { get; set; }
var boolean = searchBox.focusOnKeyboardInput;
searchBox.focusOnKeyboardInput = boolean;
Public Property FocusOnKeyboardInput As Boolean
<SearchBox FocusOnKeyboardInput="bool"/>

Property Value

Boolean

bool

true if the user can search by typing anywhere in the app; otherwise, false. The default is false.

Remarks

Note

When FocusOnKeyboardInput is set to true, there’s an issue that sometimes creates duplicate characters in the SearchBox control when using the touch keyboard. You can work around the issue by following these steps:

  1. Disable FocusOnKeyboardInput after the SearchBox receives focus. To do this, register for the PrepareForFocusOnKeyboardInput event and use the event handler to set FocusOnKeyboardInput to false.
  2. When the SearchBox loses focus, set FocusOnKeyboardInput back to true. To do this, register for the LostFocus event and use the event handler to set FocusOnKeyboardInput back to true.

When FocusOnKeyboardInput is true, keyboard input on the current thread is intercepted and textual input is redirected to the SearchBox. Only textual input will cause the SearchBox to receive focus. Non-text keys, such as arrows or Tab, are not redirected to the SearchBox. WIN/CTRL/ALT key combinations (except for Ctrl-V for paste) are also not redirected.

To do more than just set focus in the SearchBox, such as make the control visible, handle the PrepareForFocusOnKeyboardInput event.

You should set FocusOnKeyboardInput to false if the user sets focus on some other editable text field.

To learn more about when you should let users type to search, see Guidelines and checklist for search.

Applies to

See also