|
@@ -77,6 +77,12 @@ export const RoomPage = () => {
|
|
|
const chatArea: any = document.getElementById('chat-area');
|
|
|
chatArea.style.display = 'none';
|
|
|
}
|
|
|
+ const handleKeydown = (e: any) => {
|
|
|
+ if (e.target.value.trim() && e.key === 'Enter') {
|
|
|
+ enterText()
|
|
|
+ e.target.blur()
|
|
|
+ }
|
|
|
+ }
|
|
|
// 新增代码结束
|
|
|
|
|
|
return (
|
|
@@ -153,7 +159,8 @@ export const RoomPage = () => {
|
|
|
</div>
|
|
|
<div className="chat" id="chat"></div>
|
|
|
<div className="send">
|
|
|
- <input type="text" className="input" id="entry" placeholder="Enter your message"/>
|
|
|
+ <input type="text" className="input" id="entry" placeholder="Enter your message"
|
|
|
+ onKeyDown={event => handleKeydown(event)}/>
|
|
|
<button className="chat-btn" onClick={enterText}>
|
|
|
Send
|
|
|
</button>
|