mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-14 06:59:06 -04:00
Implement onKeyDown / onKeyUp & Key#isDown(key).
This commit is contained in:
parent
1e4ae9afb4
commit
05a138bc7b
4 changed files with 67 additions and 3 deletions
src/util
|
@ -131,13 +131,13 @@ var PaperScript = new function() {
|
|||
|
||||
function run(code) {
|
||||
with (paper) {
|
||||
paper.tool = /onMouse(?:Up|Down|Move|Drag)/.test(code) && new Tool();
|
||||
paper.tool = /on(?:Key|Mouse)(?:Up|Down|Move|Drag)/.test(code) && new Tool();
|
||||
var res = eval(compile(code)),
|
||||
doc = paper.document;
|
||||
if (paper.tool) {
|
||||
Base.each(['onEditOptions', 'onOptions', 'onSelect',
|
||||
'onDeselect', 'onReselect', 'onMouseDown', 'onMouseUp',
|
||||
'onMouseDrag', 'onMouseMove'], function(key) {
|
||||
'onMouseDrag', 'onMouseMove', 'onKeyDown', 'onKeyUp'], function(key) {
|
||||
try {
|
||||
paper.tool[key] = eval(key);
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue