marquete/kibo

Unregistering 'any' key

Opened this issue · 2 comments

After unregistering all the keys

kibo.down('any',null);
kibo.up('any',null);

I get:

kibo.js:181 Uncaught TypeError: Cannot read property 'length' of undefined

Hi, @antag0n1st! Thank you for reporting this - I'm so sorry I haven't been able to take care of it yet.

I was just going to replace this:

if(func === null)
  delete registeredKeys[keys];

... with something like this:

if(func === null)
  registeredKeys[keys].length = 0;

But then I reread the issue and it occurred to me that you'd expect different behaviour. Was your intention to unregister all functions registered specifically under the 'any' key, or to unregister all functions for all keys? I think the latter makes more sense, though the former is currently implemented. Then it would also make sense that unregistering 'any letter' should also unregister keys 'a' to 'z', wouldn't it? And the same for the other wildcards.

Thanks, and again, my apologies about the delay.

Yes , it should unregister all previously registered keys , the 'any' keyword should not be treated as a special key , but as a wildcard.