You can map FloatTermNew <cmd>
in an autocmd for specific filetypes:
augroup floatterm-mappings
au!
au FileType javascript nnoremap <buffer> <F5> :w<esc>:FloatermNew node %<CR>
au FileType c nnoremap <buffer> <F5> :w<esc>:FloatermNew gcc % && ./a.out && rm a.out<CR>
au FileType cpp nnoremap <buffer> <F5> :w<esc>:FloatermNew g++ % && ./a.out && rm a.out<CR>
au FileType python nnoremap <buffer> <F5> :w<esc>:FloatermNew python3 %<CR>
augroup end
The <buffer>
in nnoremap
makes sure the mapping only works for that specific buffer (rather than all buffers).