public void keyPressed(java.awt.event.KeyEvent evt)
            {
                ChannelPanel channel = (ChannelPanel) tabbedPane.getSelectedComponent();
                if (channel == null) return;

                if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                    if (chatInputPane.getText().equals("")) return;
                    try {
                        String msg = chatInputPane.getText();
                        String target = channel.name;

                        channel.history.add(msg);
                        String output = "PRIVMSG " + target + " :" + msg;
                        channel.historyCounter = channel.history.size();

                        if (msg.charAt(0) != '/') {
                            channel.connection.send(output);
                            String[] inp = {Connection.currentNick, msg.trim()};
                            channel.insertString(inp, chatStyle, false);
                            chatInputPane.setText(null);
                            evt.consume();
                            return;
                        } else {
                            channel.connection.send(msg.substring(1));
                            chatInputPane.setText(null);
                            evt.consume();
                        }

                    } catch (IOException e) {
                        try {
                            String[] msg = {null, "[Error] *** You are not connected to the server."};
                            channel.insertString(msg, errorStyle, false);
                            chatInputPane.setText(null);
                            evt.consume();
                        } catch (BadLocationException | IOException ex) {
                            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } catch (BadLocationException ex) {
                        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                if (evt.getKeyCode() == KeyEvent.VK_UP) {
                    if (channel.history.size() <= 0) return;
                    String msg = "";
                    if (channel.historyCounter > 0) msg = channel.history.get(channel.historyCounter - 1);
                    chatInputPane.setText(msg);
                    if (channel.historyCounter > 0) channel.historyCounter--;
                }
                if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
                    if (channel.historyCounter == channel.history.size()) return;
                    String msg = "";
                    if (channel.historyCounter < channel.history.size())
                        msg = channel.history.get(channel.historyCounter);
                    chatInputPane.setText(msg);
                    if (channel.historyCounter < channel.history.size()) channel.historyCounter++;
                }
                if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                    String a = chatInputPane.getText();
                    int lastSpace = a.lastIndexOf(" ") + 1;
                    if (lastSpace == -1) lastSpace = 0;
                    String nickStart = a.substring(lastSpace);

                    if (ChannelPanel.tabNicks == null || ChannelPanel.tabNicks.isEmpty())
                        ChannelPanel.tabNicks = channel.getMatchingUsers(nickStart);

                    String tabNick;
                    if (ChannelPanel.tabNicks.size() > 0) {
                        tabNick = ChannelPanel.tabNicks.get(0);
                        ChannelPanel.tabNicks.remove(tabNick);
                    } else return;

                    chatInputPane.setText(chatInputPane.getText().substring(0, lastSpace) + tabNick);
                    return;
                }
                if (ChannelPanel.tabNicks != null) ChannelPanel.tabNicks.clear();
            }