Skip to content

Commit 927ed25

Browse files
committed
Add isKeyDown(keyCode) free function
1 parent 2657b89 commit 927ed25

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Processing_api.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ inline float degrees(float r) { return PApplet::degrees(r); }
1111
inline float sq(float x) { return PApplet::sq(x); }
1212
inline float lerp(float a,float b,float t) { return PApplet::lerp(a,b,t); }
1313
inline bool* getKeysDown() { return PApplet::g_papplet ? PApplet::g_papplet->keysDown : nullptr; }
14+
inline bool isKeyDown(int keyCode) {
15+
if(!PApplet::g_papplet) return false;
16+
if(keyCode<0||keyCode>=256) return false;
17+
return PApplet::g_papplet->keysDown[keyCode];
18+
}
1419
inline bool* getMouseDown() { return PApplet::g_papplet ? PApplet::g_papplet->mouseDown : nullptr; }
1520
inline float map(float v,float i0,float i1,float o0,float o1) { return PApplet::map(v,i0,i1,o0,o1); }
1621
inline float constrain(float v,float lo,float hi) { return PApplet::constrain(v,lo,hi); }

0 commit comments

Comments
 (0)