Recognize key inputs from keyboard in flutter

This Article is posted by seven.srikanth at 23-05-2019 18:10:27

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.



Recent Articles


How to deploy flutter web site on GitHub using peanut

Posted by nikhilchaudhary12155 on 13 Oct 2019 Article


AnimatedPositioned Widget Example in Flutter

Posted by seven.srikanth on 10 Oct 2019 Article


Flutter Open-Source and directory lists

Posted by nishantkotatech on 09 Oct 2019 Article


Flutter Travelling Couple Leading Page - Flutter Web Series 3

Posted by nikhilchaudhary12155 on 05 Oct 2019 Article



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