I have had an issue for a while that affects the command line. When you go to type, for example, "/gamemode 0", the letters willl not be entered properly. All keys that could be used as a keyboard shortcut, such as command-c, command-a, command-v and so forth will start behaving as if I had used the shortcut, even if i only press the letter itself, making most commands impossible to type. This affects the command line in the chat bar, as well as command blocks. The only way I have found to fix the issues is to completely shut down minecraft and reopen it, hoping for the best.
I have this problem also but write some text in chat (do not use "a, v, c etc....") and than press shift+cmd+arrow right/left and let you select the text until you will select only one character. Than it is fixed, it has to do with Desktop switch (ctrl+arrow right/left)