Removing code duplication when handling shortcuts

Ctrl+G is still working with this patch, so the previous code seems duplicate to me.