How to make pressing the "1" key send a different character

This is the place for queries that don't fit in any of the other categories.

How to make pressing the "1" key send a different character

Postby mikerpiker » Thu Oct 31, 2013 8:00 am

Hi all. I'm a complete beginner coder and I'm trying to make a program that will allow users to do simple proofs in deductive logic. The idea is that the users enter in a statement and the statement they enter is printed as a line in their proof.

Often, however, the statements users will need to enter will include non-ascii symbols (like an arrow sign or a turnstile). Is there any way I can have my program allow users to enter these symbols by assigning key bindings to them? Something like 1 = the turnstile symbol, 2 = the arrow symbol, etc. So if the user presses the "1" key on their keyboard when prompted by raw_input() what will appear on their screen is not "1" but the turnstile symbol.

Anyone know how I might go about doing this? Or can anyone point me in the right direction to find out for myself? I'm finding it difficult to Google for help because I don't know the right language to use in describing what I'm trying to do.
mikerpiker
 
Posts: 3
Joined: Thu Oct 31, 2013 7:25 am

Re: How to make pressing the "1" key send a different charac

Postby stranac » Thu Oct 31, 2013 10:12 am

There are ways to do this, but I don't think there's a cross-platform one.
Do you need this for a specific OS? Or do you need to make it work for multiple OSs?
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: How to make pressing the "1" key send a different charac

Postby mikerpiker » Fri Nov 01, 2013 12:20 am

If I could make it work on Windows 7, that'd be fine.
mikerpiker
 
Posts: 3
Joined: Thu Oct 31, 2013 7:25 am

Re: How to make pressing the "1" key send a different charac

Postby stranac » Fri Nov 01, 2013 12:43 am

For windows, you'll probably want to use pyHook to intercept the key presses, and something like win32api.keybd_event() from pywin32 to send them.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: How to make pressing the "1" key send a different charac

Postby mikerpiker » Fri Nov 01, 2013 7:31 am

Thanks very much.
mikerpiker
 
Posts: 3
Joined: Thu Oct 31, 2013 7:25 am


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 6 guests

cron