procedure check_function_keys;
begin
  qkey := readkey;
  case qkey of

 { F1 }                #59      : help;
 { alt F1              #104     : ;                           }
 { shf F               #84      : ;                           }
 { ctl F1              #94      : ;                           }

 { F2     }            #60      : begin
                                    clear_screen;
                                    send_interrupt := TRUE;
                                  end;
 { alt F2              #105     : ;                            }
 { shf F2              #85      : ;                            }
 { ctl F2              #95      : ;                            }

 { F3     }            #61      : clear_transmit_screen;
 { alt F3              #106     : ;                            }
 { shf F3              #86      : ;                            }
 { ctl F3              #96      : ;                            }

 { F4     }            #62      : clear_receive_screen;
 { alt F4              #107     :                              }
 { shf F4              #87      : ;                            }
 { ctl F4              #97      : ;                            }

 { F5     }            #63      : view_modify_msgs;
 { alt F5 }            #108     : load_messages;
 { shf F5 }            #88      : save_messages;
 { ctl F5              #98      : ;                            }

 { F6     }            #64      : save_buffer;
 { alt F6              #109     : ;                            }
 { shf F6              #89      : ;                            }
 { ctl F6              #99      : ;                            }

 { F7     }            #65      : send_file;
 { alt F7              #110     : ;                           }
 { shf F7              #90      : ;                           }
 { ctl F7              #100     : ;                           }

 { F8     }            #66      : if mode = CW then
                                  begin
                                   change_speed;
                                    send_interrupt := TRUE;
                                  end;
 { alt F8              #111     : ;                           }
 { shf F8              #91      : ;                           }
 { ctl F8              #101     : ;                           }

 { F9                  #67      : ;                           }
 { alt F9              #112     : ;                           }
 { shf F9              #92      : ;                           }
 { ctl F9              #102     : ;                           }

 { F10 }               #68      : log_qso;
 { alt F10             #113     : ;                           }
 { shf F10             #93      : ;                           }
 { ctl F10             #103     : ;                           }

 { alt 0 }             #129     : xmt_msg(0);
 { alt 1 }             #120     : xmt_msg(1);
 { alt 2 }             #121     : xmt_msg(2);
 { alt 3 }             #122     : xmt_msg(3);
 { alt 4 }             #123     : xmt_msg(4);
 { alt 5 }             #124     : xmt_msg(5);
 { alt 6 }             #125     : xmt_msg(6);
 { alt 7 }             #126     : xmt_msg(7);
 { alt 8 }             #127     : xmt_msg(8);
 { alt 9 }             #128     : xmt_msg(9);

 { alt A }             #30      : if mode in [CW, RTTY, ASCII] then
                                  begin
                                    auto_switch := NOT auto_switch;
                                    sho_status;
                                  end;
 { alt B }             #48      : if mode in [RTTY, ASCII] then
                                    new_rtty_baud;
 { alt C }             #46      : case capture of
                                    FALSE : capture_on;
                                    TRUE  : capture_off;
                                  end;
 { alt D }             #32      : if mode = PACKET then
                                    packet_disconnect;
 { alt F }             #33      : send_file;
 { alt H }             #35      : if mode = PACKET then
                                  begin HF_Packet;
                                        sho_status;
                                  end;
 { alt I }             #23      : case mode of
                                    CW : ;
                                    RTTY,ASCII : flip_invert;
                                    PACKET : PacketID;
                                  end;
 { alt K }             #37      : if (mode = PACKET) AND
                                     (PKCall <> '') then
                                     packet_connect;
 { alt L }             #38      : if (mode = PACKET) then
                                  begin
                                    MaintainCallList;
                                    sho_status;
                                  end;
 { alt M }             #50      : begin
                                    new_mode;
                                    clear_screen;
                                  end;
 { alt P }             #25      : set_parameters;
 { alt Q }             #16      : qsignals;
 { alt R }             #19      : rst;
 { alt S }             #31      : if mode in [RTTY,ASCII] then
                                    new_rtty_shift;
 { alt V }             #47      : if mode = PACKET then
                                  begin VHF_Packet;
                                        sho_status;
                                  end;
 { alt X }             #45      : exit_request;
 { alt W }             #17      : if mode = CW then
                                  begin
                                    set_speed;
                                    send_interrupt := TRUE;
                                  end;
 { alt Y }             #21      : if mode in [RTTY,ASCII] then
                                    RYs;
 { alt Z }             #44      : if mode = PACKET then
                                    kam_cmd(^C);
 { Page Up }           #73      : review_rcv_buffer;
  end;
  rcv_interrupt := TRUE;
end;

procedure chk_kbd;
begin
  if keypressed then
  begin
    qkey := readkey;
    case file_mode of
      true: case qkey of
              ^T : case state of
                     receive  : state := transmit;
                     transmit : halt_xmt;
                     transceive : ;
                   end;
              #0 : qkey := readkey;
            end;
      false: case qkey of
               #0 : check_function_keys;
               ^T : case state of
                      receive  : state := transmit;
                      transmit : halt_xmt;
                      transceive : ;
                    end;
               #8 : del_char;
               #7,#13,' '..'z' : add_char(qkey);
               ^Z : if mode = PACKET then add_char(qkey);
               ^C : if mode = AMTOR then add_char(qkey);
             end;
    end;
  if qkey = ^P then
    case pause_flag of
      FALSE : begin
                if mode in [ASCII,CW,RTTY] then
                  state := receive;
                pause_flag := TRUE;
              end;
       TRUE : begin
                if mode in [ASCII,CW,RTTY] then
                  state := transmit;
                pause_flag := FALSE;
              end;
    end;

  end;
  if (mode in [CW,RTTY,ASCII]) AND
     (auto_switch = TRUE)    AND
     (inp_ptr <> out_ptr)        then state := transmit;

end;



