Wrapped pulsing in closure to fix mutable key variable.

Hey David,

The reason it isn't working is that every time the for loops around it updates the value of `key`. There's various ways to fix that by binding the callback to a locally-scoped key, I've just chosen to wrap pulsing in a closure.