diff options
author | Marvin Borner | 2019-01-30 18:47:55 +0100 |
---|---|---|
committer | Marvin Borner | 2019-01-30 18:47:55 +0100 |
commit | d1b2addcf3d33bb5a261c54f88b4d6130aa8952f (patch) | |
tree | ec8adb35cc232b4b523935d453bd34b770864579 /public/scripts/chat.js | |
parent | f4bc9e771b5f79ff95ed2069b9c1402679241ddb (diff) |
Added enter listener
Diffstat (limited to 'public/scripts/chat.js')
-rw-r--r-- | public/scripts/chat.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/public/scripts/chat.js b/public/scripts/chat.js index 056dc09..cc224c2 100644 --- a/public/scripts/chat.js +++ b/public/scripts/chat.js @@ -164,10 +164,21 @@ function chat() { } /** + * Sends a message of the text input field + * @returns {Promise<void>} + */ + async function sendMessageFromInput() { + return await sendMessage($('#message').val()) & $('#message').val('') + } + + /** * Click events */ $(document).ready(() => { - $('#send_message').on('click', async () => await sendMessage($('#message').val()) & $('#message').val('')); + $('#send_message').on('click', async () => await sendMessageFromInput()); + $('#message').on('keydown', async e => { + if (e.key === 'Enter') await sendMessageFromInput() + }); // FABs $('#add_peer_id').on('click', async () => await connect($('#peer_id').val())); |