Skip to content

Commit 16ef9df

Browse files
committed
Updated capture docs and values
1 parent 76918e7 commit 16ef9df

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/boot/Config.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var GetFastValue = require('../utils/object/GetFastValue');
1111
var GetValue = require('../utils/object/GetValue');
1212
var IsPlainObject = require('../utils/object/IsPlainObject');
1313
var MATH = require('../math/const');
14+
var NumberArray = require('../utils/array/NumberArray');
1415
var RND = require('../math/random-data-generator/RandomDataGenerator');
1516
var NOOP = require('../utils/NOOP');
1617
var DefaultPlugins = require('../plugins/DefaultPlugins');
@@ -63,7 +64,7 @@ var ValueToColor = require('../display/color/ValueToColor');
6364
* @typedef {object} KeyboardInputConfig
6465
*
6566
* @property {*} [target=window] - Where the Keyboard Manager listens for keyboard input events.
66-
* @property {boolean} [capture=true] - Whether keyboard input events have `preventDefault` called on them automatically.
67+
* @property {(boolean|integer[])} [capture] - `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it's set to all the space key, cursors and all alphanumeric keys. Or, set to 'false' to disable.
6768
*/
6869

6970
/**
@@ -415,9 +416,21 @@ var Config = new Class({
415416
this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window);
416417

417418
/**
418-
* @const {boolean} Phaser.Boot.Config#inputKeyboardCapture - Should `preventDefault` be called automatically on every key non-modified press (true), or let each Key object set it (false)
419+
* @const {(boolean|integer[])} Phaser.Boot.Config#inputKeyboardCapture - `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it's set to all alphanumeric keys. Or, set to 'false' to disable.
419420
*/
420-
this.inputKeyboardCapture = GetValue(config, 'input.keyboard.capture', true);
421+
var defaultCaptures = [ 32, 38, 39, 40, 42 ];
422+
423+
defaultCaptures = defaultCaptures.concat(NumberArray(48, 57));
424+
defaultCaptures = defaultCaptures.concat(NumberArray(65, 90));
425+
426+
var keyboardCapture = GetValue(config, 'input.keyboard.capture', defaultCaptures);
427+
428+
if (!Array.isArray(keyboardCapture))
429+
{
430+
keyboardCapture = [];
431+
}
432+
433+
this.inputKeyboardCapture = keyboardCapture;
421434

422435
/**
423436
* @const {(boolean|object)} Phaser.Boot.Config#inputMouse - Enable the Mouse Plugin. This can be disabled in games that don't need mouse input.
@@ -575,7 +588,7 @@ var Config = new Class({
575588
var bgc = GetValue(config, 'backgroundColor', 0);
576589

577590
/**
578-
* @const {Phaser.Display.Color} Phaser.Boot.Config#backgroundColor - The background color of the game canvas. The default is black.
591+
* @const {Phaser.Display.Color} Phaser.Boot.Config#backgroundColor - The background color of the game canvas. The default is black. This value is ignored if `transparent` is set to `true`.
579592
*/
580593
this.backgroundColor = ValueToColor(bgc);
581594

0 commit comments

Comments
 (0)