private void txtMessage_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { btnSend_Click(null, null); e.Handled = true; lastTypingNotification = DateTime.UtcNow.AddSeconds(-10); } else { DateTime current = DateTime.UtcNow; if ((current - lastTypingNotification).TotalSeconds > 5) { lastTypingNotification = current; _network.SendTypingNotification(); } } }