Filter by Widgets


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: ...
)
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

Horizontal List View

Check out this article on Horizontal List View

Read full post

How to get the Width and Height of the Screen in Flutter?

Check out this article on How to get the Width and Height of the Screen in Flutter?

Read full post

How to add a Footer Buttons in Flutter?

Check out this article on How to add a Footer Buttons in Flutter?

Read full post

TextField in Flutter

Check out this article on TextField in Flutter

Read full post

How to Draw a Triangle using Canvas in Flutter?

Check out this article on How to Draw a Triangle using Canvas in Flutter?

Read full post

url_launcher Package - Lets Launch URL, Send Email, Make Call or Send SMS in Flutter

Check out this article on url_launcher Package - Lets Launch URL, Send Email, Make Call or Send SMS in Flutter

Read full post

Error: The name 'RangeSlider' is defined in the libraries 'package:flutter/src/material/range_slider.dart' and 'package:flutter_range_slider/src/flutter_range_slider.dart'.

Check out this article on Error: The name 'RangeSlider' is defined in the libraries 'package:flutter/src/material/range_slider.dart' and 'package:flutter_range_slider/src/flutter_range_slider.dart'.

Read full post

How to create a persistent bottom sheet in Flutter?

Check out this article on How to create a persistent bottom sheet in Flutter?

Read full post

How to draw a Decorative Horizontal line in Flutter?

Check out this article on How to draw a Decorative Horizontal line in Flutter?

Read full post

How to fetch an Image from Internet in Flutter

Check out this article on How to fetch an Image from Internet in Flutter

Read full post

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

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License , and code samples are licensed under the BSD License.