Recognize key inputs from keyboard in flutter

This Article is posted by seven.srikanth at 5/23/2019 6:10:27 PM



You need to use RawKeyboardListener. This is the widget that calls a callback whenever the user presses or releases a key on a keyboard.
A RawKeyboardListener is useful for listening to raw key events and hardware buttons that are represented as keys. Typically used by games and other apps that use keyboard for purposes other than text entry.
Below is the example code for recognizing a backspace. 
FocusScope.of(context).requestFocus(_focusNode);
RawKeyboardListener(
focusNode: _focusNode,
onKey: (RawKeyEvent event) {
if(event.runtimeType == RawKeyDownEvent &&
(even.logicalKey.keyId == KeyCode.backspace)) {
_focusNode.unfocus();
... // your code here
}   
},
child: ...
)

Tags: keyboard;








0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.


© 2018 - Fluttercentral | Email to me - seven.srikanth@gmail.com