Slice key matches array

To prevent keys registered or unregistered during dispatch from breaking
the dispatching.
Merge pull request #1474 from Stuk/key-manager-slice

Slice key matches array