buffer: fix multi-key sequence handling