Skip to content

Commit 4df0861

Browse files
committed
adds input event, also fixes changed event docs
1 parent 7165458 commit 4df0861

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/core/p5.Element.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,28 @@ p5.Element.prototype.mouseOver = function (fxn) {
241241
* This can be used to attach an element specific event listener.
242242
*
243243
* @method changed
244-
* @param {Function} fxn function to be fired when mouse is
245-
* moved over the element.
244+
* @param {Function} fxn function to be fired when the value of an element changes.
246245
* @return {p5.Element}
247246
*/
248247
p5.Element.prototype.changed = function (fxn) {
249248
attachListener('change', fxn, this);
250249
return this;
251250
};
252251

252+
/**
253+
* The .input() function is called when any user input is detected with an element.
254+
* The input event is often used to detect keystrokes in a input element,
255+
* or changes on a slider element. This can be used to attach an element specific event listener.
256+
*
257+
* @method input
258+
* @param {Function} fxn function to be fired on user input.
259+
* @return {p5.Element}
260+
*/
261+
p5.Element.prototype.input = function (fxn) {
262+
attachListener('input', fxn, this);
263+
return this;
264+
};
265+
253266
/**
254267
* The .mouseOut() function is called once after every time a
255268
* mouse moves off the element. This can be used to attach an

0 commit comments

Comments
 (0)