Typing Events

Last Edit: Mar 03 2020

All official SDKs support typing events out of the box and are handled out of the box on all channels with the typing_events featured enabled.

There are two types of events related to user typing: typing.start and typing.stop, both are sent client-side in response to user input. If you are building your own chat integration on top of an API client instead of using an SDK, we recommend following a few basic rules:

  1. Send the typing.start only the first time a user starts typing
  2. Once the user stops typing for longer than two seconds, send the typing.stop event

// sends an event typing.start to all channel watchers
await channel.keystroke();

// sends an event typing.stop to all channel watchers
await channel.stopTyping();
                    

// sends a typing.start event if it's been more than 3000 ms since the last event
channel.keystroke(new EventCallback() {
    @Override
    public void onSuccess(EventResponse response) {
    }

    @Override
    public void onError(String errMsg, int errCode) {
    }

});

// sends an event typing.stop to all channel participants
channel.stopTyping(new EventCallback() {
    @Override
    public void onSuccess(EventResponse response) {
    }

    @Override
    public void onError(String errMsg, int errCode) {
    }

});
                    

// Send a typing start event.
channel.send(eventType: .typingStart).subscribe().disposed(by: disposeBag)

// Send a typing stop event.
channel.send(eventType: .typingStop).subscribe().disposed(by: disposeBag)
                    

// sends a typing.start event if it's been more than 3000 ms since the last event
channel.keystroke()

// sends an event typing.stop to all channel participants
channel.stopTyping()
                    

// sends an event typing.start to all channel watchers
await channel.keyStroke();

// sends an event typing.stop to all channel watchers
await channel.stopTyping();