phaser/v2-community/docs/src_input_Keyboard.js.html

2222 lines
63 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Phaser Source: src/input/Keyboard.js</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/default.css">
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-inverse">
<div style="position: absolute; width: 143px; height: 31px; right: 10px; top: 10px; z-index: 1050"><a href="http://phaser.io"><img src="img/phaser.png" border="0" /></a></div>
<div class="navbar-inner">
<a class="brand" href="index.html">Phaser API</a>
<ul class="nav">
<li class="dropdown">
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-0">
<a href="Phaser.html">Phaser</a>
</li>
<li class="class-depth-0">
<a href="PIXI.html">PIXI</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-0">
<a href="EarCut.html">EarCut</a>
</li>
<li class="class-depth-0">
<a href="Event.html">Event</a>
</li>
<li class="class-depth-0">
<a href="EventTarget.html">EventTarget</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Animation.html">Animation</a>
</li>
<li class="class-depth-1">
<a href="Phaser.AnimationManager.html">AnimationManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.AnimationParser.html">AnimationParser</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ArraySet.html">ArraySet</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ArrayUtils.html">ArrayUtils</a>
</li>
<li class="class-depth-1">
<a href="Phaser.AudioSprite.html">AudioSprite</a>
</li>
<li class="class-depth-1">
<a href="Phaser.BitmapData.html">BitmapData</a>
</li>
<li class="class-depth-1">
<a href="Phaser.BitmapText.html">BitmapText</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Bullet.html">Bullet</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Button.html">Button</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Cache.html">Cache</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Camera.html">Camera</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Canvas.html">Canvas</a>
</li>
<li class="class-depth-1">
<a href="Phaser.CanvasPool.html">CanvasPool</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Circle.html">Circle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Color.html">Color</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Angle.html">Angle</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Animation.html">Animation</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.AutoCull.html">AutoCull</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Bounds.html">Bounds</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.BringToTop.html">BringToTop</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Core.html">Core</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Crop.html">Crop</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Delta.html">Delta</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Destroy.html">Destroy</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.FixedToCamera.html">FixedToCamera</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Health.html">Health</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.InCamera.html">InCamera</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.InputEnabled.html">InputEnabled</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.InWorld.html">InWorld</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.LifeSpan.html">LifeSpan</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.LoadTexture.html">LoadTexture</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Overlap.html">Overlap</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.PhysicsBody.html">PhysicsBody</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Reset.html">Reset</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.ScaleMinMax.html">ScaleMinMax</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Smoothed.html">Smoothed</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Create.html">Create</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Creature.html">Creature</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Device.html">Device</a>
</li>
<li class="class-depth-1">
<a href="Phaser.DeviceButton.html">DeviceButton</a>
</li>
<li class="class-depth-1">
<a href="Phaser.DOM.html">DOM</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Easing.html">Easing</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Back.html">Back</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Bounce.html">Bounce</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Circular.html">Circular</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Cubic.html">Cubic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Elastic.html">Elastic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Exponential.html">Exponential</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Linear.html">Linear</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Quartic.html">Quartic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Quintic.html">Quintic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Ellipse.html">Ellipse</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Events.html">Events</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Filter.html">Filter</a>
</li>
<li class="class-depth-1">
<a href="Phaser.FlexGrid.html">FlexGrid</a>
</li>
<li class="class-depth-1">
<a href="Phaser.FlexLayer.html">FlexLayer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Frame.html">Frame</a>
</li>
<li class="class-depth-1">
<a href="Phaser.FrameData.html">FrameData</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Game.html">Game</a>
</li>
<li class="class-depth-1">
<a href="Phaser.GameObjectCreator.html">GameObjectCreator</a>
</li>
<li class="class-depth-1">
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Gamepad.html">Gamepad</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Graphics.html">Graphics</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Group.html">Group</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Hermite.html">Hermite</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Image.html">Image</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ImageCollection.html">ImageCollection</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Input.html">Input</a>
</li>
<li class="class-depth-1">
<a href="Phaser.InputHandler.html">InputHandler</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Key.html">Key</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Keyboard.html">Keyboard</a>
</li>
<li class="class-depth-1">
<a href="Phaser.KeyCode.html">KeyCode</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Line.html">Line</a>
</li>
<li class="class-depth-1">
<a href="Phaser.LinkedList.html">LinkedList</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Loader.html">Loader</a>
</li>
<li class="class-depth-1">
<a href="Phaser.LoaderParser.html">LoaderParser</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Math.html">Math</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Matrix.html">Matrix</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Mouse.html">Mouse</a>
</li>
<li class="class-depth-1">
<a href="Phaser.MSPointer.html">MSPointer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Net.html">Net</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Particle.html">Particle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Particles.html">Particles</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Particles.Arcade.html">Arcade</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Path.html">Path</a>
</li>
<li class="class-depth-1">
<a href="Phaser.PathFollower.html">PathFollower</a>
</li>
<li class="class-depth-1">
<a href="Phaser.PathPoint.html">PathPoint</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Physics.html">Physics</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Physics.Arcade.html">Arcade</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Arcade.TilemapCollision.html">TilemapCollision</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Physics.Ninja.html">Ninja</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.AABB.html">AABB</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Body.html">Body</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Circle.html">Circle</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Tile.html">Tile</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Physics.P2.html">P2</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Body.html">Body</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.BodyDebug.html">BodyDebug</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.DistanceConstraint.html">DistanceConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.FixtureList.html">FixtureList</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.GearConstraint.html">GearConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.InversePointProxy.html">InversePointProxy</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.LockConstraint.html">LockConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Material.html">Material</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PointProxy.html">PointProxy</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PrismaticConstraint.html">PrismaticConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.RevoluteConstraint.html">RevoluteConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.RotationalSpring.html">RotationalSpring</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Spring.html">Spring</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Plugin.html">Plugin</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Plugin.PathManager.html">PathManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.PluginManager.html">PluginManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Point.html">Point</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Pointer.html">Pointer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.PointerMode.html">PointerMode</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Polygon.html">Polygon</a>
</li>
<li class="class-depth-1">
<a href="Phaser.QuadTree.html">QuadTree</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Rectangle.html">Rectangle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RenderTexture.html">RenderTexture</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RetroFont.html">RetroFont</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Rope.html">Rope</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RoundedRectangle.html">RoundedRectangle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ScaleManager.html">ScaleManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Signal.html">Signal</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SignalBinding.html">SignalBinding</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SinglePad.html">SinglePad</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Sound.html">Sound</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SoundManager.html">SoundManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Sprite.html">Sprite</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SpriteBatch.html">SpriteBatch</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Stage.html">Stage</a>
</li>
<li class="class-depth-1">
<a href="Phaser.State.html">State</a>
</li>
<li class="class-depth-1">
<a href="Phaser.StateManager.html">StateManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Text.html">Text</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tile.html">Tile</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tilemap.html">Tilemap</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TilemapParser.html">TilemapParser</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tileset.html">Tileset</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TileSprite.html">TileSprite</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Time.html">Time</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Timer.html">Timer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TimerEvent.html">TimerEvent</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Touch.html">Touch</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tween.html">Tween</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TweenData.html">TweenData</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TweenManager.html">TweenManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Utils.html">Utils</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Utils.Debug.html">Debug</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Video.html">Video</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Weapon.html">Weapon</a>
</li>
<li class="class-depth-1">
<a href="Phaser.World.html">World</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BaseTexture.html">BaseTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasBuffer.html">CanvasBuffer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasGraphics.html">CanvasGraphics</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasMaskManager.html">CanvasMaskManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasRenderer.html">CanvasRenderer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasTinter.html">CanvasTinter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.ComplexPrimitiveShader.html">ComplexPrimitiveShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DisplayObject.html">DisplayObject</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DisplayObjectContainer.html">DisplayObjectContainer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.FilterTexture.html">FilterTexture</a>
</li>
<li class="class-depth-2">
<a href="PIXI.Phaser.GraphicsData.html">Phaser.GraphicsData</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PIXI.html">PIXI</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PixiFastShader.html">PixiFastShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PixiShader.html">PixiShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PrimitiveShader.html">PrimitiveShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Sprite.html">Sprite</a>
</li>
<li class="class-depth-1">
<a href="PIXI.StripShader.html">StripShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Texture.html">Texture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLBlendModeManager.html">WebGLBlendModeManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLFastSpriteBatch.html">WebGLFastSpriteBatch</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLFilterManager.html">WebGLFilterManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLRenderer.html">WebGLRenderer</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-0">
<a href="global.html#ANGLE_DOWN">ANGLE_DOWN</a>
</li>
<li class="class-depth-0">
<a href="global.html#ANGLE_LEFT">ANGLE_LEFT</a>
</li>
<li class="class-depth-0">
<a href="global.html#ANGLE_NORTH_EAST">ANGLE_NORTH_EAST</a>
</li>
<li class="class-depth-0">
<a href="global.html#ANGLE_NORTH_WEST">ANGLE_NORTH_WEST</a>
</li>
<li class="class-depth-0">
<a href="global.html#ANGLE_RIGHT">ANGLE_RIGHT</a>
</li>
<li class="class-depth-0">
<a href="global.html#ANGLE_SOUTH_EAST">ANGLE_SOUTH_EAST</a>
</li>
<li class="class-depth-0">
<a href="global.html#ANGLE_SOUTH_WEST">ANGLE_SOUTH_WEST</a>
</li>
<li class="class-depth-0">
<a href="global.html#ANGLE_UP">ANGLE_UP</a>
</li>
<li class="class-depth-0">
<a href="global.html#arc">arc</a>
</li>
<li class="class-depth-0">
<a href="global.html#AUTO">AUTO</a>
</li>
<li class="class-depth-0">
<a href="global.html#beginFill">beginFill</a>
</li>
<li class="class-depth-0">
<a href="global.html#bezierCurveTo">bezierCurveTo</a>
</li>
<li class="class-depth-0">
<a href="global.html#BITMAPDATA">BITMAPDATA</a>
</li>
<li class="class-depth-0">
<a href="global.html#BITMAPTEXT">BITMAPTEXT</a>
</li>
<li class="class-depth-0">
<a href="global.html#blendModes">blendModes</a>
</li>
<li class="class-depth-0">
<a href="global.html#BOTTOM_CENTER">BOTTOM_CENTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#BOTTOM_LEFT">BOTTOM_LEFT</a>
</li>
<li class="class-depth-0">
<a href="global.html#BOTTOM_RIGHT">BOTTOM_RIGHT</a>
</li>
<li class="class-depth-0">
<a href="global.html#BUTTON">BUTTON</a>
</li>
<li class="class-depth-0">
<a href="global.html#CANVAS">CANVAS</a>
</li>
<li class="class-depth-0">
<a href="global.html#CANVAS_FILTER">CANVAS_FILTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#CENTER">CENTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#CIRCLE">CIRCLE</a>
</li>
<li class="class-depth-0">
<a href="global.html#clear">clear</a>
</li>
<li class="class-depth-0">
<a href="global.html#CREATURE">CREATURE</a>
</li>
<li class="class-depth-0">
<a href="global.html#destroyCachedSprite">destroyCachedSprite</a>
</li>
<li class="class-depth-0">
<a href="global.html#displayList">displayList</a>
</li>
<li class="class-depth-0">
<a href="global.html#DOWN">DOWN</a>
</li>
<li class="class-depth-0">
<a href="global.html#drawCircle">drawCircle</a>
</li>
<li class="class-depth-0">
<a href="global.html#drawEllipse">drawEllipse</a>
</li>
<li class="class-depth-0">
<a href="global.html#drawPolygon">drawPolygon</a>
</li>
<li class="class-depth-0">
<a href="global.html#drawRect">drawRect</a>
</li>
<li class="class-depth-0">
<a href="global.html#drawRoundedRect">drawRoundedRect</a>
</li>
<li class="class-depth-0">
<a href="global.html#drawShape">drawShape</a>
</li>
<li class="class-depth-0">
<a href="global.html#ELLIPSE">ELLIPSE</a>
</li>
<li class="class-depth-0">
<a href="global.html#emit">emit</a>
</li>
<li class="class-depth-0">
<a href="global.html#EMITTER">EMITTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#endFill">endFill</a>
</li>
<li class="class-depth-0">
<a href="global.html#GAMES">GAMES</a>
</li>
<li class="class-depth-0">
<a href="global.html#generateTexture">generateTexture</a>
</li>
<li class="class-depth-0">
<a href="global.html#getBounds">getBounds</a>
</li>
<li class="class-depth-0">
<a href="global.html#getLocalBounds">getLocalBounds</a>
</li>
<li class="class-depth-0">
<a href="global.html#GRAPHICS">GRAPHICS</a>
</li>
<li class="class-depth-0">
<a href="global.html#GROUP">GROUP</a>
</li>
<li class="class-depth-0">
<a href="global.html#HEADLESS">HEADLESS</a>
</li>
<li class="class-depth-0">
<a href="global.html#HORIZONTAL">HORIZONTAL</a>
</li>
<li class="class-depth-0">
<a href="global.html#IMAGE">IMAGE</a>
</li>
<li class="class-depth-0">
<a href="global.html#LANDSCAPE">LANDSCAPE</a>
</li>
<li class="class-depth-0">
<a href="global.html#LEFT">LEFT</a>
</li>
<li class="class-depth-0">
<a href="global.html#LEFT_BOTTOM">LEFT_BOTTOM</a>
</li>
<li class="class-depth-0">
<a href="global.html#LEFT_CENTER">LEFT_CENTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#LEFT_TOP">LEFT_TOP</a>
</li>
<li class="class-depth-0">
<a href="global.html#LINE">LINE</a>
</li>
<li class="class-depth-0">
<a href="global.html#lineStyle">lineStyle</a>
</li>
<li class="class-depth-0">
<a href="global.html#lineTo">lineTo</a>
</li>
<li class="class-depth-0">
<a href="global.html#listeners">listeners</a>
</li>
<li class="class-depth-0">
<a href="global.html#MATRIX">MATRIX</a>
</li>
<li class="class-depth-0">
<a href="global.html#mixin">mixin</a>
</li>
<li class="class-depth-0">
<a href="global.html#moveTo">moveTo</a>
</li>
<li class="class-depth-0">
<a href="global.html#NONE">NONE</a>
</li>
<li class="class-depth-0">
<a href="global.html#off">off</a>
</li>
<li class="class-depth-0">
<a href="global.html#on">on</a>
</li>
<li class="class-depth-0">
<a href="global.html#once">once</a>
</li>
<li class="class-depth-0">
<a href="global.html#PENDING_ATLAS">PENDING_ATLAS</a>
</li>
<li class="class-depth-2">
<a href="global.html#Phaser.Path#numPointsreturn%257Bnumber%257DThetotalnumberofPathPointsinthisPath.">Phaser.Path#numPoints
return {number} The total number of PathPoints in this Path.</a>
</li>
<li class="class-depth-0">
<a href="global.html#POINT">POINT</a>
</li>
<li class="class-depth-0">
<a href="global.html#POINTER">POINTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#POLYGON">POLYGON</a>
</li>
<li class="class-depth-0">
<a href="global.html#PORTRAIT">PORTRAIT</a>
</li>
<li class="class-depth-0">
<a href="global.html#quadraticCurveTo">quadraticCurveTo</a>
</li>
<li class="class-depth-0">
<a href="global.html#RECTANGLE">RECTANGLE</a>
</li>
<li class="class-depth-0">
<a href="global.html#removeAllListeners">removeAllListeners</a>
</li>
<li class="class-depth-0">
<a href="global.html#RENDERTEXTURE">RENDERTEXTURE</a>
</li>
<li class="class-depth-0">
<a href="global.html#RETROFONT">RETROFONT</a>
</li>
<li class="class-depth-0">
<a href="global.html#RIGHT">RIGHT</a>
</li>
<li class="class-depth-0">
<a href="global.html#RIGHT_BOTTOM">RIGHT_BOTTOM</a>
</li>
<li class="class-depth-0">
<a href="global.html#RIGHT_CENTER">RIGHT_CENTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#RIGHT_TOP">RIGHT_TOP</a>
</li>
<li class="class-depth-0">
<a href="global.html#ROPE">ROPE</a>
</li>
<li class="class-depth-0">
<a href="global.html#ROUNDEDRECTANGLE">ROUNDEDRECTANGLE</a>
</li>
<li class="class-depth-0">
<a href="global.html#scaleModes">scaleModes</a>
</li>
<li class="class-depth-0">
<a href="global.html#SPRITE">SPRITE</a>
</li>
<li class="class-depth-0">
<a href="global.html#SPRITEBATCH">SPRITEBATCH</a>
</li>
<li class="class-depth-0">
<a href="global.html#stopImmediatePropagation">stopImmediatePropagation</a>
</li>
<li class="class-depth-0">
<a href="global.html#stopPropagation">stopPropagation</a>
</li>
<li class="class-depth-0">
<a href="global.html#TEXT">TEXT</a>
</li>
<li class="class-depth-0">
<a href="global.html#TILEMAP">TILEMAP</a>
</li>
<li class="class-depth-0">
<a href="global.html#TILEMAPLAYER">TILEMAPLAYER</a>
</li>
<li class="class-depth-0">
<a href="global.html#TILESPRITE">TILESPRITE</a>
</li>
<li class="class-depth-0">
<a href="global.html#TOP_CENTER">TOP_CENTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#TOP_LEFT">TOP_LEFT</a>
</li>
<li class="class-depth-0">
<a href="global.html#TOP_RIGHT">TOP_RIGHT</a>
</li>
<li class="class-depth-0">
<a href="global.html#UP">UP</a>
</li>
<li class="class-depth-0">
<a href="global.html#updateLocalBounds">updateLocalBounds</a>
</li>
<li class="class-depth-0">
<a href="global.html#VERSION">VERSION</a>
</li>
<li class="class-depth-0">
<a href="global.html#VERTICAL">VERTICAL</a>
</li>
<li class="class-depth-0">
<a href="global.html#VIDEO">VIDEO</a>
</li>
<li class="class-depth-0">
<a href="global.html#WEBGL">WEBGL</a>
</li>
<li class="class-depth-0">
<a href="global.html#WEBGL_FILTER">WEBGL_FILTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#WEBGL_MULTI">WEBGL_MULTI</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Core<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Game.html">Game</a></li>
<li class="class-depth-1"><a href="Phaser.Group.html">Group</a></li>
<li class="class-depth-1"><a href="Phaser.World.html">World</a></li>
<li class="class-depth-1"><a href="Phaser.Loader.html">Loader</a></li>
<li class="class-depth-1"><a href="Phaser.Cache.html">Cache</a></li>
<li class="class-depth-1"><a href="Phaser.Time.html">Time</a></li>
<li class="class-depth-1"><a href="Phaser.Camera.html">Camera</a></li>
<li class="class-depth-1"><a href="Phaser.StateManager.html">State Manager</a></li>
<li class="class-depth-1"><a href="Phaser.TweenManager.html">Tween Manager</a></li>
<li class="class-depth-1"><a href="Phaser.SoundManager.html">Sound Manager</a></li>
<li class="class-depth-1"><a href="Phaser.Input.html">Input Manager</a></li>
<li class="class-depth-1"><a href="Phaser.ScaleManager.html">Scale Manager</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Game Objects<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.GameObjectFactory.html">Factory (game.add)</a></li>
<li class="class-depth-1"><a href="Phaser.GameObjectCreator.html">Creator (game.make)</a></li>
<li class="class-depth-1"><a href="Phaser.Sprite.html">Sprite</a></li>
<li class="class-depth-1"><a href="Phaser.Image.html">Image</a></li>
<li class="class-depth-1"><a href="Phaser.Sound.html">Sound</a></li>
<li class="class-depth-1"><a href="Phaser.Video.html">Video</a></li>
<li class="class-depth-1"><a href="Phaser.Particles.Arcade.Emitter.html">Particle Emitter</a></li>
<li class="class-depth-1"><a href="Phaser.Particle.html">Particle</a></li>
<li class="class-depth-1"><a href="Phaser.Text.html">Text</a></li>
<li class="class-depth-1"><a href="Phaser.Tween.html">Tween</a></li>
<li class="class-depth-1"><a href="Phaser.BitmapText.html">BitmapText</a></li>
<li class="class-depth-1"><a href="Phaser.Tilemap.html">Tilemap</a></li>
<li class="class-depth-1"><a href="Phaser.BitmapData.html">BitmapData</a></li>
<li class="class-depth-1"><a href="Phaser.RetroFont.html">RetroFont</a></li>
<li class="class-depth-1"><a href="Phaser.Button.html">Button</a></li>
<li class="class-depth-1"><a href="Phaser.Animation.html">Animation</a></li>
<li class="class-depth-1"><a href="Phaser.Graphics.html">Graphics</a></li>
<li class="class-depth-1"><a href="Phaser.RenderTexture.html">RenderTexture</a></li>
<li class="class-depth-1"><a href="Phaser.TileSprite.html">TileSprite</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Geometry<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Circle.html">Circle</a></li>
<li class="class-depth-1"><a href="Phaser.Ellipse.html">Ellipse</a></li>
<li class="class-depth-1"><a href="Phaser.Line.html">Line</a></li>
<li class="class-depth-1"><a href="Phaser.Matrix.html">Matrix</a></li>
<li class="class-depth-1"><a href="Phaser.Point.html">Point</a></li>
<li class="class-depth-1"><a href="Phaser.Polygon.html">Polygon</a></li>
<li class="class-depth-1"><a href="Phaser.Rectangle.html">Rectangle</a></li>
<li class="class-depth-1"><a href="Phaser.RoundedRectangle.html">Rounded Rectangle</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Physics<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Physics.Arcade.html">Arcade Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.Arcade.Body.html">Body</a></li>
<li class="class-depth-2"><a href="Phaser.Weapon.html">Weapon</a></li>
<li class="class-depth-1"><a href="Phaser.Physics.P2.html">P2 Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.Body.html">Body</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.Spring.html">Spring</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a></li>
<li class="class-depth-1"><a href="Phaser.Physics.Ninja.html">Ninja Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.Body.html">Body</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Input<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.InputHandler.html">Input Handler</a></li>
<li class="class-depth-1"><a href="Phaser.Pointer.html">Pointer</a></li>
<li class="class-depth-1"><a href="Phaser.DeviceButton.html">Device Button</a></li>
<li class="class-depth-1"><a href="Phaser.Mouse.html">Mouse</a></li>
<li class="class-depth-1"><a href="Phaser.Keyboard.html">Keyboard</a></li>
<li class="class-depth-1"><a href="Phaser.Key.html">Key</a></li>
<li class="class-depth-1"><a href="Phaser.KeyCode.html">Key Codes</a></li>
<li class="class-depth-1"><a href="Phaser.Gamepad.html">Gamepad</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Community<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="http://phaser.io">Phaser Web Site</a></li>
<li class="class-depth-1"><a href="https://github.com/photonstorm/phaser">Phaser Github</a></li>
<li class="class-depth-1"><a href="http://phaser.io/examples">Phaser Examples</a></li>
<li class="class-depth-1"><a href="https://github.com/photonstorm/phaser-plugins">Phaser Plugins</a></li>
<li class="class-depth-1"><a href="http://www.html5gamedevs.com/forum/14-phaser/">Forum</a></li>
<li class="class-depth-1"><a href="http://stackoverflow.com/questions/tagged/phaser-framework">Stack Overflow</a></li>
<li class="class-depth-1"><a href="http://phaser.io/learn">Tutorials</a></li>
<li class="class-depth-1"><a href="http://phaser.io/community/newsletter">Newsletter</a></li>
<li class="class-depth-1"><a href="http://phaser.io/community/twitter">Twitter</a></li>
<li class="class-depth-1"><a href="http://phaser.io/community/slack">Slack</a></li>
<li class="class-depth-1"><a href="http://phaser.io/community/donate">Donate</a></li>
<li class="class-depth-1"><a href="https://www.codeandweb.com/texturepacker/phaser">Texture Packer</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div id="main">
<h1 class="page-title">Source: src/input/Keyboard.js</h1>
<section>
<article>
<pre class="sunlight-highlight-javascript linenums">/**
* @author Richard Davey &lt;rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* The Keyboard class monitors keyboard input and dispatches keyboard events.
*
* _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting.
* See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details.
*
* Also please be aware that certain browser extensions can disable or override Phaser keyboard handling.
* For example the Chrome extension vimium is known to disable Phaser from using the D key. And there are others.
* So please check your extensions before opening Phaser issues.
*
* @class Phaser.Keyboard
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
*/
Phaser.Keyboard = function (game) {
/**
* @property {Phaser.Game} game - Local reference to game.
*/
this.game = game;
/**
* Keyboard input will only be processed if enabled.
* @property {boolean} enabled
* @default
*/
this.enabled = true;
/**
* @property {object} event - The most recent DOM event from keydown or keyup. This is updated every time a new key is pressed or released.
*/
this.event = null;
/**
* @property {object} pressEvent - The most recent DOM event from keypress.
*/
this.pressEvent = null;
/**
* @property {object} callbackContext - The context under which the callbacks are run.
*/
this.callbackContext = this;
/**
* @property {function} onDownCallback - This callback is invoked every time a key is pressed down, including key repeats when a key is held down.
*/
this.onDownCallback = null;
/**
* @property {function} onPressCallback - This callback is invoked every time a DOM onkeypress event is raised, which is only for printable keys.
*/
this.onPressCallback = null;
/**
* @property {function} onUpCallback - This callback is invoked every time a key is released.
*/
this.onUpCallback = null;
/**
* @property {array&lt;Phaser.Key>} _keys - The array the Phaser.Key objects are stored in.
* @private
*/
this._keys = [];
/**
* @property {array} _capture - The array the key capture values are stored in.
* @private
*/
this._capture = [];
/**
* @property {function} _onKeyDown
* @private
* @default
*/
this._onKeyDown = null;
/**
* @property {function} _onKeyPress
* @private
* @default
*/
this._onKeyPress = null;
/**
* @property {function} _onKeyUp
* @private
* @default
*/
this._onKeyUp = null;
/**
* @property {number} _i - Internal cache var
* @private
*/
this._i = 0;
/**
* @property {number} _k - Internal cache var
* @private
*/
this._k = 0;
};
Phaser.Keyboard.prototype = {
/**
* Add callbacks to the Keyboard handler so that each time a key is pressed down or released the callbacks are activated.
*
* @method Phaser.Keyboard#addCallbacks
* @param {object} context - The context under which the callbacks are run.
* @param {function} [onDown=null] - This callback is invoked every time a key is pressed down.
* @param {function} [onUp=null] - This callback is invoked every time a key is released.
* @param {function} [onPress=null] - This callback is invoked every time the onkeypress event is raised.
*/
addCallbacks: function (context, onDown, onUp, onPress) {
this.callbackContext = context;
if (onDown !== undefined &amp;&amp; onDown !== null)
{
this.onDownCallback = onDown;
}
if (onUp !== undefined &amp;&amp; onUp !== null)
{
this.onUpCallback = onUp;
}
if (onPress !== undefined &amp;&amp; onPress !== null)
{
this.onPressCallback = onPress;
}
},
/**
* If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method.
* The Key object can then be polled, have events attached to it, etc.
*
* @method Phaser.Keyboard#addKey
* @param {integer} keycode - The {@link Phaser.KeyCode keycode} of the key.
* @return {Phaser.Key} The Key object which you can store locally and reference directly.
*/
addKey: function (keycode) {
if (!this._keys[keycode])
{
this._keys[keycode] = new Phaser.Key(this.game, keycode);
this.addKeyCapture(keycode);
}
return this._keys[keycode];
},
/**
* A practical way to create an object containing user selected hotkeys.
*
* For example,
*
* addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } );
*
* would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object.
*
* @method Phaser.Keyboard#addKeys
* @param {object} keys - A key mapping object, i.e. `{ 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S }` or `{ 'up': 52, 'down': 53 }`.
* @return {object} An object containing the properties mapped to {@link Phaser.Key} values.
*/
addKeys: function (keys) {
var output = {};
for (var key in keys)
{
output[key] = this.addKey(keys[key]);
}
return output;
},
/**
* Removes a Key object from the Keyboard manager.
*
* @method Phaser.Keyboard#removeKey
* @param {integer} keycode - The {@link Phaser.KeyCode keycode} of the key to remove.
*/
removeKey: function (keycode) {
if (this._keys[keycode])
{
this._keys[keycode] = null;
this.removeKeyCapture(keycode);
}
},
/**
* Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right.
*
* @method Phaser.Keyboard#createCursorKeys
* @return {object} An object containing properties: `up`, `down`, `left` and `right` of {@link Phaser.Key} objects.
*/
createCursorKeys: function () {
return this.addKeys({ 'up': Phaser.KeyCode.UP, 'down': Phaser.KeyCode.DOWN, 'left': Phaser.KeyCode.LEFT, 'right': Phaser.KeyCode.RIGHT });
},
/**
* Starts the Keyboard event listeners running (keydown and keyup). They are attached to the window.
* This is called automatically by Phaser.Input and should not normally be invoked directly.
*
* @method Phaser.Keyboard#start
* @protected
*/
start: function () {
if (this.game.device.cocoonJS)
{
return;
}
if (this._onKeyDown !== null)
{
// Avoid setting multiple listeners
return;
}
var _this = this;
this._onKeyDown = function (event) {
return _this.processKeyDown(event);
};
this._onKeyUp = function (event) {
return _this.processKeyUp(event);
};
this._onKeyPress = function (event) {
return _this.processKeyPress(event);
};
window.addEventListener('keydown', this._onKeyDown, false);
window.addEventListener('keyup', this._onKeyUp, false);
window.addEventListener('keypress', this._onKeyPress, false);
},
/**
* Stops the Keyboard event listeners from running (keydown, keyup and keypress). They are removed from the window.
*
* @method Phaser.Keyboard#stop
*/
stop: function () {
window.removeEventListener('keydown', this._onKeyDown);
window.removeEventListener('keyup', this._onKeyUp);
window.removeEventListener('keypress', this._onKeyPress);
this._onKeyDown = null;
this._onKeyUp = null;
this._onKeyPress = null;
},
/**
* Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the window.
* Also clears all key captures and currently created Key objects.
*
* @method Phaser.Keyboard#destroy
*/
destroy: function () {
this.stop();
this.clearCaptures();
this._keys.length = 0;
this._i = 0;
},
/**
* By default when a key is pressed Phaser will not stop the event from propagating up to the browser.
* There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll.
*
* The `addKeyCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser
* and cause the default browser behavior.
*
* Pass in either a single keycode or an array/hash of keycodes.
*
* @method Phaser.Keyboard#addKeyCapture
* @param {integer|integer[]|object} keycode - Either a single {@link Phaser.KeyCode keycode} or an array/hash of keycodes such as `[65, 67, 68]`.
*/
addKeyCapture: function (keycode) {
if (typeof keycode === 'object')
{
for (var key in keycode)
{
this._capture[keycode[key]] = true;
}
}
else
{
this._capture[keycode] = true;
}
},
/**
* Removes an existing key capture.
*
* @method Phaser.Keyboard#removeKeyCapture
* @param {integer} keycode - The {@link Phaser.KeyCode keycode} to remove capturing of.
*/
removeKeyCapture: function (keycode) {
delete this._capture[keycode];
},
/**
* Clear all set key captures.
*
* @method Phaser.Keyboard#clearCaptures
*/
clearCaptures: function () {
this._capture = {};
},
/**
* Updates all currently defined keys.
*
* @method Phaser.Keyboard#update
*/
update: function () {
this._i = this._keys.length;
while (this._i--)
{
if (this._keys[this._i])
{
this._keys[this._i].update();
}
}
},
/**
* Process the keydown event.
*
* @method Phaser.Keyboard#processKeyDown
* @param {KeyboardEvent} event
* @protected
*/
processKeyDown: function (event) {
this.event = event;
if (!this.game.input.enabled || !this.enabled)
{
return;
}
var key = event.keyCode;
// The event is being captured but another hotkey may need it
if (this._capture[key])
{
event.preventDefault();
}
if (!this._keys[key])
{
this._keys[key] = new Phaser.Key(this.game, key);
}
this._keys[key].processKeyDown(event);
this._k = key;
if (this.onDownCallback)
{
this.onDownCallback.call(this.callbackContext, event);
}
},
/**
* Process the keypress event.
*
* @method Phaser.Keyboard#processKeyPress
* @param {KeyboardEvent} event
* @protected
*/
processKeyPress: function (event) {
this.pressEvent = event;
if (!this.game.input.enabled || !this.enabled)
{
return;
}
if (this.onPressCallback)
{
this.onPressCallback.call(this.callbackContext, String.fromCharCode(event.charCode), event);
}
},
/**
* Process the keyup event.
*
* @method Phaser.Keyboard#processKeyUp
* @param {KeyboardEvent} event
* @protected
*/
processKeyUp: function (event) {
this.event = event;
if (!this.game.input.enabled || !this.enabled)
{
return;
}
var key = event.keyCode;
if (this._capture[key])
{
event.preventDefault();
}
if (!this._keys[key])
{
this._keys[key] = new Phaser.Key(this.game, key);
}
this._keys[key].processKeyUp(event);
if (this.onUpCallback)
{
this.onUpCallback.call(this.callbackContext, event);
}
},
/**
* Resets all Keys.
*
* @method Phaser.Keyboard#reset
* @param {boolean} [hard=true] - A soft reset won't reset any events or callbacks that are bound to the Keys. A hard reset will.
*/
reset: function (hard) {
if (hard === undefined) { hard = true; }
this.event = null;
var i = this._keys.length;
while (i--)
{
if (this._keys[i])
{
this._keys[i].reset(hard);
}
}
},
/**
* Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down,
* or was pressed down longer ago than then given duration.
*
* @method Phaser.Keyboard#downDuration
* @param {integer} keycode - The {@link Phaser.KeyCode keycode} of the key to check: i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR.
* @param {number} [duration=50] - The duration within which the key is considered as being just pressed. Given in ms.
* @return {boolean} True if the key was pressed down within the given duration, false if not or null if the Key wasn't found.
*/
downDuration: function (keycode, duration) {
if (this._keys[keycode])
{
return this._keys[keycode].downDuration(duration);
}
else
{
return null;
}
},
/**
* Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down,
* or was pressed down longer ago than then given duration.
*
* @method Phaser.Keyboard#upDuration
* @param {Phaser.KeyCode|integer} keycode - The keycode of the key to check, i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR.
* @param {number} [duration=50] - The duration within which the key is considered as being just released. Given in ms.
* @return {boolean} True if the key was released within the given duration, false if not or null if the Key wasn't found.
*/
upDuration: function (keycode, duration) {
if (this._keys[keycode])
{
return this._keys[keycode].upDuration(duration);
}
else
{
return null;
}
},
/**
* Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser.
*
* @method Phaser.Keyboard#isDown
* @param {integer} keycode - The {@link Phaser.KeyCode keycode} of the key to check: i.e. Phaser.KeyCode.UP or Phaser.KeyCode.SPACEBAR.
* @return {boolean} True if the key is currently down, false if not or null if the Key wasn't found.
*/
isDown: function (keycode) {
if (this._keys[keycode])
{
return this._keys[keycode].isDown;
}
else
{
return null;
}
}
};
/**
* Returns the string value of the most recently pressed key.
* @name Phaser.Keyboard#lastChar
* @property {string} lastChar - The string value of the most recently pressed key.
* @readonly
*/
Object.defineProperty(Phaser.Keyboard.prototype, "lastChar", {
get: function () {
if (this.event.charCode === 32)
{
return '';
}
else
{
return String.fromCharCode(this.pressEvent.charCode);
}
}
});
/**
* Returns the most recently pressed Key. This is a Phaser.Key object and it changes every time a key is pressed.
* @name Phaser.Keyboard#lastKey
* @property {Phaser.Key} lastKey - The most recently pressed Key.
* @readonly
*/
Object.defineProperty(Phaser.Keyboard.prototype, "lastKey", {
get: function () {
return this._keys[this._k];
}
});
Phaser.Keyboard.prototype.constructor = Phaser.Keyboard;
/**
* A key code represents a physical key on a keyboard.
*
* The KeyCode class contains commonly supported keyboard key codes which can be used
* as keycode`-parameters in several {@link Phaser.Keyboard} and {@link Phaser.Key} methods.
*
* _Note_: These values should only be used indirectly, eg. as `Phaser.KeyCode.KEY`.
* Future versions may replace the actual values, such that they remain compatible with `keycode`-parameters.
* The current implementation maps to the {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode KeyboardEvent.keyCode} property.
*
* _Note_: Use `Phaser.KeyCode.KEY` instead of `Phaser.Keyboard.KEY` to refer to a key code;
* the latter approach is supported for compatibility.
*
* @class Phaser.KeyCode
*/
Phaser.KeyCode = {
/** @static */
A: "A".charCodeAt(0),
/** @static */
B: "B".charCodeAt(0),
/** @static */
C: "C".charCodeAt(0),
/** @static */
D: "D".charCodeAt(0),
/** @static */
E: "E".charCodeAt(0),
/** @static */
F: "F".charCodeAt(0),
/** @static */
G: "G".charCodeAt(0),
/** @static */
H: "H".charCodeAt(0),
/** @static */
I: "I".charCodeAt(0),
/** @static */
J: "J".charCodeAt(0),
/** @static */
K: "K".charCodeAt(0),
/** @static */
L: "L".charCodeAt(0),
/** @static */
M: "M".charCodeAt(0),
/** @static */
N: "N".charCodeAt(0),
/** @static */
O: "O".charCodeAt(0),
/** @static */
P: "P".charCodeAt(0),
/** @static */
Q: "Q".charCodeAt(0),
/** @static */
R: "R".charCodeAt(0),
/** @static */
S: "S".charCodeAt(0),
/** @static */
T: "T".charCodeAt(0),
/** @static */
U: "U".charCodeAt(0),
/** @static */
V: "V".charCodeAt(0),
/** @static */
W: "W".charCodeAt(0),
/** @static */
X: "X".charCodeAt(0),
/** @static */
Y: "Y".charCodeAt(0),
/** @static */
Z: "Z".charCodeAt(0),
/** @static */
ZERO: "0".charCodeAt(0),
/** @static */
ONE: "1".charCodeAt(0),
/** @static */
TWO: "2".charCodeAt(0),
/** @static */
THREE: "3".charCodeAt(0),
/** @static */
FOUR: "4".charCodeAt(0),
/** @static */
FIVE: "5".charCodeAt(0),
/** @static */
SIX: "6".charCodeAt(0),
/** @static */
SEVEN: "7".charCodeAt(0),
/** @static */
EIGHT: "8".charCodeAt(0),
/** @static */
NINE: "9".charCodeAt(0),
/** @static */
NUMPAD_0: 96,
/** @static */
NUMPAD_1: 97,
/** @static */
NUMPAD_2: 98,
/** @static */
NUMPAD_3: 99,
/** @static */
NUMPAD_4: 100,
/** @static */
NUMPAD_5: 101,
/** @static */
NUMPAD_6: 102,
/** @static */
NUMPAD_7: 103,
/** @static */
NUMPAD_8: 104,
/** @static */
NUMPAD_9: 105,
/** @static */
NUMPAD_MULTIPLY: 106,
/** @static */
NUMPAD_ADD: 107,
/** @static */
NUMPAD_ENTER: 108,
/** @static */
NUMPAD_SUBTRACT: 109,
/** @static */
NUMPAD_DECIMAL: 110,
/** @static */
NUMPAD_DIVIDE: 111,
/** @static */
F1: 112,
/** @static */
F2: 113,
/** @static */
F3: 114,
/** @static */
F4: 115,
/** @static */
F5: 116,
/** @static */
F6: 117,
/** @static */
F7: 118,
/** @static */
F8: 119,
/** @static */
F9: 120,
/** @static */
F10: 121,
/** @static */
F11: 122,
/** @static */
F12: 123,
/** @static */
F13: 124,
/** @static */
F14: 125,
/** @static */
F15: 126,
/** @static */
COLON: 186,
/** @static */
EQUALS: 187,
/** @static */
COMMA: 188,
/** @static */
UNDERSCORE: 189,
/** @static */
PERIOD: 190,
/** @static */
QUESTION_MARK: 191,
/** @static */
TILDE: 192,
/** @static */
OPEN_BRACKET: 219,
/** @static */
BACKWARD_SLASH: 220,
/** @static */
CLOSED_BRACKET: 221,
/** @static */
QUOTES: 222,
/** @static */
BACKSPACE: 8,
/** @static */
TAB: 9,
/** @static */
CLEAR: 12,
/** @static */
ENTER: 13,
/** @static */
SHIFT: 16,
/** @static */
CONTROL: 17,
/** @static */
ALT: 18,
/** @static */
CAPS_LOCK: 20,
/** @static */
ESC: 27,
/** @static */
SPACEBAR: 32,
/** @static */
PAGE_UP: 33,
/** @static */
PAGE_DOWN: 34,
/** @static */
END: 35,
/** @static */
HOME: 36,
/** @static */
LEFT: 37,
/** @static */
UP: 38,
/** @static */
RIGHT: 39,
/** @static */
DOWN: 40,
/** @static */
PLUS: 43,
/** @static */
MINUS: 44,
/** @static */
INSERT: 45,
/** @static */
DELETE: 46,
/** @static */
HELP: 47,
/** @static */
NUM_LOCK: 144
};
// Duplicate Phaser.KeyCode values in Phaser.Keyboard for compatibility
for (var key in Phaser.KeyCode)
{
if (Phaser.KeyCode.hasOwnProperty(key) &amp;&amp; !key.match(/[a-z]/))
{
Phaser.Keyboard[key] = Phaser.KeyCode[key];
}
}
</pre>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
Phaser Copyright © 2012-2016 Photon Storm Ltd.
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
on Tue Dec 06 2016 23:48:54 GMT+0000 (GMT Standard Time) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
<br clear="both">
</div>
</div>
<script src="scripts/sunlight.js"></script>
<script src="scripts/sunlight.javascript.js"></script>
<script src="scripts/sunlight-plugin.doclinks.js"></script>
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
<script src="scripts/sunlight-plugin.menu.js"></script>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/jquery.scrollTo.js"></script>
<script src="scripts/jquery.localScroll.js"></script>
<script src="scripts/bootstrap-dropdown.js"></script>
<script src="scripts/toc.js"></script>
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
<script>
$( function () {
$( "#toc" ).toc( {
anchorName : function(i, heading, prefix) {
return $(heading).attr("id") || ( prefix + i );
},
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : 60
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
} );
</script>
</body>
</html>