Input Management + building UI elements
Note that when the specified event is triggered or heard, we don’t
exactly call a function, we refer to a listener, which can
be understood like a function call, so long as we handle the event that
is passed.
<table>
<tbody>
<tr>
<td> </td>
<td><button onmousedown="clickDpadYellow()" onmouseup="clickableDpadReleased()" class="button yellow round">Y</button></td>
<td> </td>
</tr>
<tr>
<td><button onmousedown="clickDpadBlue()" onmouseup="clickableDpadReleased()" class="button blue round">X</button></td>
<td> </td>
<td><button onmousedown="clickDpadRed()" onmouseup="clickableDpadReleased()" class="button red round">B</button></td>
</tr>
<tr>
<td> </td>
<td><button onmousedown="clickDpadGreen()" onmouseup="clickableDpadReleased()" class="button green round">A</button></td>
<td> </td>
</tr>
<tr>
</tbody>
</table>CSS and JS to give visual
feedbackfunction drawTimer() {
// Draw the background
context.fillStyle = "#000000";
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillRect(0, 0, width, height);
// Draw the fill
context.fillStyle = "#00FF00";
var fillVal = Math.min(Math.max(val / max, 0), 1);
context.fillRect(0, 0, fillVal * width, height);
// Decrease the fill
val = val - 1;
}