In the picture below, I want to delete the tag when I press the backspace key.
but I don`t detect backspace event.
this is my code.
Widget build(BuildContext context) {
return RawKeyboardListener(
focusNode: FocusNode(),
onKey: (RawKeyEvent event) {
print(event);
if(event.isKeyPressed(LogicalKeyboardKey.backspace)) {
print("press backspace");
if(_tagsStringContent.length > 0) {
if (_tagsStringContent.length == 1 && _showPrefixIcon == true) {
widget.onDelete(_tagsStringContent[_tagsStringContent.length-1]);
setState(() {
_tagsStringContent.removeLast();
_showPrefixIcon = false;
});
} else {
widget.onDelete(_tagsStringContent[_tagsStringContent.length-1]);
setState(() {
_tagsStringContent.removeLast();
});
}
}
}
},
autofocus: true,
child: TextField( (...skip)
)
)
)
RawKeyEvent only works in computer backspace.
how to detect backspace key in keyboard?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.