473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

catching keypress in canvas tag

I am trying to catch keypresses in my canvas tag, but it appears that
that is not valid.

I may try to just create a hidden input box that will allow me to catch
keypresses.

I am trying to write a very simple asteroids game for a presentation on
Ajax in July, to show that javascript can do more than it was able to a
couple of years ago.

I would like to maneuver the ship by using arrow keys.

Thanx for any suggestions.

Jun 22 '06 #1
3 2627
James Black wrote:
I am trying to catch keypresses in my canvas tag, but it appears that
that is not valid.

I may try to just create a hidden input box that will allow me to catch
keypresses.
I've had no problem with onkeydown attached to the <body>
I am trying to write a very simple asteroids game for a presentation on
Ajax in July, to show that javascript can do more than it was able to a
couple of years ago.
Like what?
I would like to maneuver the ship by using arrow keys.
That wasn't a problem 2 years ago, either.
Thanx for any suggestions.


Look here: http://members.dslextreme.com/users/tony23/bricks.htm

--
"The most convoluted explanation that fits all the available and made-up
facts is the most likely to be believed by conspiracy theorists"
Jun 23 '06 #2

Tony wrote:
I've had no problem with onkeydown attached to the <body>


I didn't think about putting it in the body tag. I tried it, and it
solved my problem.

For my game you can look at
http://dante.acomp.usf.edu:9090/aste...asteroids.html

It is very basic right now, but it works on Firefox 1.5, and will serve
as the start of my presentation.

Jun 23 '06 #3
James Black wrote:
I am trying to catch keypresses in my canvas tag, but it appears that
that is not valid.

I may try to just create a hidden input box that will allow me to catch
keypresses.

I am trying to write a very simple asteroids game for a presentation on
Ajax in July, to show that javascript can do more than it was able to a
couple of years ago.

I would like to maneuver the ship by using arrow keys.

Thanx for any suggestions.


This is a pretty impressive javascript game:

http://www.wolf5k.com/

:-)
Jun 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mickel Grönroos | last post by:
Hi, I'm trying to put an Tkinter.Entry of fixed size onto a specific location on a canvas using the place manager. The idea is that one can double-click a rectangle object on a canvas to get an...
9
by: shannonl | last post by:
Hi all, For some reason this bind is calling the donothing function, like it should, but is then allowing the text to be inserted into the Text widget. Here is the code: ...
1
by: Nagachandra Sekhar Grandhi | last post by:
I placed a combobox control on User control and this user control was placed on a form and I tried to catch the keys pressed on that combo box, but I am unable to do it. I set the property of...
9
by: OpticTygre | last post by:
How would I be able to capture multiple key presses, such as Alt+Shift+D in a form's KeyPress and KeyDown events? Thanks in advance. -Jason
2
TMS
by: TMS | last post by:
Schools over!!! Now its time to play. I would like to learn how to make objects move from one location to the next on a canvas widget. For example: from Tkinter import * class square:...
6
by: Nebulism | last post by:
I have been attempting to utilize a draw command script that loads a canvas, and through certain mouse events, draws rectangles. The original code is from...
2
by: devnew | last post by:
hi i am new to tkinter and would like some help with canvas i am doing validation of contents of a folder and need to show the ok/error messages on a canvas resultdisplay =Canvas(...)...
10
by: blaine | last post by:
Hey everyone! I'm not very good with Tk, and I am using a very simple canvas to draw some pictures (this relates to that nokia screen emulator I had a post about a few days ago). Anyway, all is...
4
by: moondaddy | last post by:
I have a wpf project where I use a canvas to drag shapes around. when I drag a shape beyond the right or bottom side I get scrollbars which is good. I also get scrollbars when I zoom in and a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.