Skip to content

Commit 77ca0d0

Browse files
committed
The WebAudioSoundManager.unlock method will now listen for keydown events in order to unlock the Audio Context, as well as touch and pointer events, making it more accessible
1 parent 3b5e28f commit 77ca0d0

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/sound/webaudio/WebAudioSoundManager.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,31 +227,36 @@ var WebAudioSoundManager = new Class({
227227
{
228228
var _this = this;
229229

230+
var body = document.body;
231+
230232
var unlockHandler = function unlockHandler ()
231233
{
232234
if (_this.context)
233235
{
234236
_this.context.resume().then(function ()
235237
{
236-
document.body.removeEventListener('touchstart', unlockHandler);
237-
document.body.removeEventListener('touchend', unlockHandler);
238-
document.body.removeEventListener('click', unlockHandler);
238+
body.removeEventListener('touchstart', unlockHandler);
239+
body.removeEventListener('touchend', unlockHandler);
240+
body.removeEventListener('click', unlockHandler);
241+
body.removeEventListener('keydown', unlockHandler);
239242

240243
_this.unlocked = true;
241244
}, function ()
242245
{
243-
document.body.removeEventListener('touchstart', unlockHandler);
244-
document.body.removeEventListener('touchend', unlockHandler);
245-
document.body.removeEventListener('click', unlockHandler);
246+
body.removeEventListener('touchstart', unlockHandler);
247+
body.removeEventListener('touchend', unlockHandler);
248+
body.removeEventListener('click', unlockHandler);
249+
body.removeEventListener('keydown', unlockHandler);
246250
});
247251
}
248252
};
249253

250-
if (document.body)
254+
if (body)
251255
{
252-
document.body.addEventListener('touchstart', unlockHandler, false);
253-
document.body.addEventListener('touchend', unlockHandler, false);
254-
document.body.addEventListener('click', unlockHandler, false);
256+
body.addEventListener('touchstart', unlockHandler, false);
257+
body.addEventListener('touchend', unlockHandler, false);
258+
body.addEventListener('click', unlockHandler, false);
259+
body.addEventListener('keydown', unlockHandler, false);
255260
}
256261
},
257262

0 commit comments

Comments
 (0)