Skip to content

Commit

Permalink
Remove deprecated isKeyPressed property
Browse files Browse the repository at this point in the history
  • Loading branch information
limzykenneth committed Jan 21, 2025
1 parent f6c8fcf commit 789cd5b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
5 changes: 1 addition & 4 deletions src/events/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ function keyboard(p5, fn){
* </code>
* </div>
*/
fn.isKeyPressed = false;
fn.keyIsPressed = false; // khan
fn.keyIsPressed = false;

/**
* A `String` system variable that contains the value of the last key typed.
Expand Down Expand Up @@ -444,7 +443,6 @@ function keyboard(p5, fn){
// prevent multiple firings
return;
}
this.isKeyPressed = true;
this.keyIsPressed = true;
this.keyCode = e.which;
this._downKeys[e.which] = true;
Expand Down Expand Up @@ -617,7 +615,6 @@ function keyboard(p5, fn){
this._downKeys[e.which] = false;

if (!this._areDownKeys()) {
this.isKeyPressed = false;
this.keyIsPressed = false;
}

Expand Down
16 changes: 0 additions & 16 deletions test/unit/events/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,6 @@ suite('Keyboard Events', function() {
});
});

suite('p5.prototype.isKeyPressed', function() {
test('isKeyPressed should be a boolean', function() {
assert.isBoolean(myp5.isKeyPressed);
});

test('isKeyPressed should be true on key press', function() {
window.dispatchEvent(new KeyboardEvent('keydown'));
assert.strictEqual(myp5.isKeyPressed, true);
});

test('isKeyPressed should be false on key up', function() {
window.dispatchEvent(new KeyboardEvent('keyup'));
assert.strictEqual(myp5.isKeyPressed, false);
});
});

suite('p5.prototype.key', function() {
test('key should be a string', async function() {
window.dispatchEvent(new KeyboardEvent('keydown', { key: 's' }));
Expand Down

0 comments on commit 789cd5b

Please sign in to comment.