keyStroke method

Future<void> keyStroke([
  1. String? parentId
])

First of the EventType.typingStart and EventType.typingStop events based on the users keystrokes. Call this on every keystroke.

Implementation

Future<void> keyStroke([String? parentId]) async {
  if (config?.typingEvents == false) {
    return;
  }

  client.logger.info('start typing');
  final now = DateTime.now();

  if (_lastTypingEvent == null ||
      now.difference(_lastTypingEvent!).inSeconds >= 2) {
    _lastTypingEvent = now;
    await sendEvent(Event(
      type: EventType.typingStart,
      parentId: parentId,
    ));
  }
}