onKeyPress method

void onKeyPress(
  1. VirtualKey key
)

Implementation

void onKeyPress(VirtualKey key) {
  switch (key.type) {
    case KeyType.character:
      if (key.label != null) {
        _textBuffer.write(key.label); // 문자 키 추가
      }
    case KeyType.backspace:
      if (_textBuffer.isNotEmpty) {
        _removeLastString(_textBuffer);
      }
    case KeyType.enter:
      _textBuffer.write('\n');
    case KeyType.space:
      _textBuffer.write(' ');
    case KeyType.clear:
      _textBuffer.clear();
  }
  _lastInputKey = key;
  notifyListeners();
}