// Adapted from libtermkey: https://github.com/neovim/libtermkey