Every time you click the button, you add another keydown
binding to #textarea
. So if you click the button 5 times, then when you press Enter the keydown binding will be run 5 times.
You should move $('#postDiv').on('keydown', '#textarea', ...)
outside the function, and just do it once in the document ready handler.