onKeyPress method

void onKeyPress(
  1. VirtualKey key
)

Implementation

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