Typing Events

Last Edit: Sep 22 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
channelController.keystroke().enqueue(result -> Unit.INSTANCE);
// sends an event typing.stop to all channel participants
channelController.stopTyping().enqueue(result -> Unit.INSTANCE);
                    

// Send a typing start event.
let channel = Client.shared.channel(type: .messaging, id: "general")
channel.send(eventType: .typingStart) { (result) in
    // handle result
}
// Send a typing stop event.
channel.send(eventType: .typingStop) { (result) in /**/ }
                    

// 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();