If you don't mind having gvim installed you can run gvim in commandline mode with gvim -v. Then you should have a version of commandline vim able to access the keyboard.
Also if gvim is invoked as vim it will act like it was invoked as gvim -v, so if you do something like this:
mkdir -p ~/bin
ln -s /usr/bin/gvim ~/bin/vim
echo "PATH=~/bin:$PATH' >>...
You need to install the ncurses (libncurses-dev) development
package (as the error message at the end states). If you
are using a Ubuntu system, you can use the following command:
sudo apt install libncurses-dev
@christian-brabant has the gist of it. At least one of them needs to be an installation outside of your package manager. Of course, if you are using an add-on package manager like conda, you can probably find them and stick them in different (virtual) environments.
To do it yourself.
Having multiple versions of software on a system only really requires, that ...
Building Vim from the source with the right flags is the general solution.
git clone https://github.com/vim/vim.git
./configure --with-x=yes --disable-gui
The last command will probably raise an error message, which means
you need to install dependencies. Experienced users know how to proceed, but
if it's your first time on this, bad news is ...