Uncaught TypeError: Cannot read property 'toUpperCase' of undefined

I have been experiencing this error for weeks, and I’m fed up with it.

The error:

Uncaught TypeError: Cannot read property ‘toUpperCase’ of undefined
at Controls.loadKeyBinds (Kade Engine.js:11889)
at Controls.setKeyboardScheme (Kade Engine.js:10756)
at new Controls (Kade Engine.js:10245)
at new PlayerSettings (Kade Engine.js:21368)
at Function.PlayerSettings.init (Kade Engine.js:21376)
at TitleState.create (Kade Engine.js:22702)
at flixel_FlxGame.switchState (Kade Engine.js:29323)
at flixel_FlxGame.create (Kade Engine.js:29208)
at flixel_FlxGame.__dispatchEvent (Kade Engine.js:4909)
at flixel_FlxGame.__dispatchEvent (Kade Engine.js:5734)

Source code for the game I’m building: (i’m building to html5)

Seems like you’re feeding FlxKey.fromString() a null value. Check your FlxG.save.data.x data

In JavaScript almost everything is an object, null and undefined are exceptions. This error occurs when a property is read or a function is called on an undefined variable. Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.

If you are not sure a variable that will always have some value, the best practice is to check the value of variables for null or undefined before using them. To avoid getting these types of errors, you need to make sure that the variables you are trying to read do have the correct value. This can be done in various ways. You can do if checks before dealing with objects whose values are bound to change:

if (myVar !== undefined) {


if (typeof(myVar) !== 'undefined') {