ctrl p作为自定义(用户定义)按钮处于 Flutter 状态

oknwwptz  于 2023-05-01  发布在  Flutter
关注(0)|答案(1)|浏览(153)

我想设计一个按钮在Flutter,当它被按下它执行(Ctrl+P)的功能,就像键盘一样
尝试在不使用任何库的情况下从 Flutter 卷筒纸打印到热敏打印机

mftmpeh8

mftmpeh81#

试试用你的纽扣包这个

RawKeyboardListener(
          focusNode: FocusNode(),
          onKey: (RawKeyEvent event) {
            if (event.isControlPressed && event.isKeyPressed(LogicalKeyboardKey.keyP)) {
              // Ctrl+P is pressed
              print('Ctrl+P is pressed');
              // Perform your action here, such as showing a print dialog
            }
          },
          child: Container(
            child: Text('Press Ctrl+P'),
          ),
        )

相关问题